cancel
Showing results for 
Search instead for 
Did you mean: 
Data Engineering
Join discussions on data engineering best practices, architectures, and optimization strategies within the Databricks Community. Exchange insights and solutions with fellow data engineers.
cancel
Showing results for 
Search instead for 
Did you mean: 

Time Travel Error when selecting from materialized view (Azure Databricks)

EAnthemNHC1
New Contributor III

Hey - running into an error this morning that was brought to my attention via failed refreshes from PowerBI. We have a materialized view that, when queried with the standard pattern of 'select col1 from {schema}.table_name', returns an error of 'Cannot time travel Delta Table to version XXXX'. This is odd to me for a few reasons.

1: materialized views don't support time travel as far as I can tell: https://learn.microsoft.com/en-us/azure/databricks/ldp/dbsql/materialized#limitations

2: The query isn't specifying any version. 

I've tried changing computes between warehouse and serverless and I still get the same errors. There are other MV's in that pipeline with all the same dependencies, that are not having this issue. 

Has anyone ran into this, or have any insight? Thanks

 

2 REPLIES 2

saurabh18cs
Honored Contributor II

Hi @EAnthemNHC1 there could be multiple reasons :

1) The materialized view is backed by a Delta table. If the underlying Delta table has been vacuumed (old versions removed), but the materialized view metadata or refresh logic tries to access a specific (now-missing) version, you’ll get a “Cannot time travel Delta Table to version XXXX” error.

2) If a refresh failed or was interrupted, the MV metadata may be out of sync with the underlying data.

trying forcing a refresh on MV

REFRESH MATERIALIZED VIEW {schema}.{table_name}

or worst trying re-creating a MV

Br

nayan_wylde
Esteemed Contributor
DESCRIBE HISTORY catalog.schema.table_name;

Check the earliest available version. If the version mentioned in the error is older than what’s retained, that’s the issue.

Also, inspect the materialized view’s backing pipeline in Catalog Explorer → Refresh Details to see if it attempted incremental refresh.