How can I resolve the "View is stale; it must be re-created" error in Athena?
Last updated: 2020-06-04
When I run a view query in Amazon Athena, I get a "stale view" error like this: "SYNTAX_ERROR: line 1:15: View 'awsdatacatalog.mydatabase.myview' is stale; it must be re-created".
Athena reports a stale view if the table or database that's specified in the view query doesn't exist—or if you modify the table definition after you create the view. For example, suppose you create a view and then run an ALTER TABLE ADD PARTITION statement on the same table. Your view query fails with a stale view error. The stale view error also happens if you run an AWS Glue crawler to update the table definition. For more information, see Considerations for Views.
To prevent "stale view" errors, recreate the view whenever you modify the underlying table or databases.