By using AWS re:Post, you agree to the AWS re:Post Terms of Use

How do I resolve a VIEW_IS_STALE error in Athena?

1 minute read
0

When I run a view query in Amazon Athena, I get a VIEW_IS_STALE error similar to the following: "VIEW_IS_STALE: line 1:15: View 'awsdatacatalog.mydatabase.myview' is stale or in invalid state".

Resolution

Athena reports a stale view under one or more of the following conditions:

  • The table or database that's specified in the view query doesn't exist.
  • You try to modify the table definition after you create the view.
  • You try to update the schema or metadata in a referenced table when you recreate or update the table.

For example, your query fails with a VIEW_IS_STALE error when you create a view and then run an ALTER TABLE ADD COLUMNS statement on the same table. The stale view error also happens when you run an AWS Glue crawler to update the table definition. For more information, see Considerations for views.

To prevent VIEW_IS_STALE errors, recreate the view whenever you modify the underlying tables or databases. You can also replace/update the existing view with the updated table definition by adding the OR REPLACE clause in the CREATE VIEW statement.

Related information

Working with views

AWS OFFICIAL
AWS OFFICIALUpdated 4 months ago