Time travel to last month fails
An auditor asks for a Delta table as it was 20 days ago. SELECT * FROM sales VERSION AS OF ... fails because data files are missing, yet DESCRIBE HISTORY still shows that version. Why, and what settings control this?
Think it through or sketch an answer first, then open the hint or the solution.
Show a hint
History lives in the transaction log; old data files are removed by a separate command.
Show the solution
The log still lists the version, but VACUUM has deleted data files older than the retention period, which is 7 days by default (delta.deletedFileRetentionDuration). Log entries are kept longer (30 days by default, delta.logRetentionDuration), which is why history still shows it. If you need 30 days of time travel, raise the file retention to at least 30 days, accepting the storage cost. Time travel is not a backup strategy for long-term audit needs.
Example (SQL)
ALTER TABLE sales SET TBLPROPERTIES (
'delta.deletedFileRetentionDuration' = 'interval 30 days',
'delta.logRetentionDuration' = 'interval 60 days'
);
Common mistakes
- Running VACUUM with a very short retention to save storage, then needing the old versions.
- Treating time travel as a backup: use snapshots or deep clones for long-term retention.
How did you do? Your answer is saved in this browser and comes back for revision later.
Learn more
- Time Travel, History & RestoreDelta Lake
- OPTIMIZE, Z-ORDER & VACUUMDelta Lake