Respect the 7-day floor
DRY RUN first, and treat 168 hours as the minimum retention for any production vacuum.
See the dry-run habit →One aggressive VACUUM can permanently delete the old data files that time travel, audits, and incremental readers depend on — and Delta's retention safety check is the only thing standing in the way. Learn the 7-day floor, the dry-run habit, and how to raise the floor per table instead of disabling the guard.
Built for engineers who need an answer they can test in the next notebook, job run, or incident review.
DRY RUN first, and treat 168 hours as the minimum retention for any production vacuum.
See the dry-run habit →One RETAIN 24 HOURS job quietly deleted a month of recoverable history. Audit your vacuum jobs and raise the floor per table.
See the three-step fix →The log entries survive; the files don't. Time travel needs the old parquet files physically present.
Get the answer →VACUUM removes data files that are no longer in the latest state of the transaction log and are older than a retention threshold. That threshold defaults to 7 days — and the official docs are blunt about the cost: run VACUUM on a Delta table and you lose the ability to time travel back to a version older than the retention period. The files are physically deleted; the versions they belonged to are gone for good.
Delta Lake ships a safety check that refuses RETAIN values under 7 days unless you set spark.databricks.delta.retentionDurationCheck.enabled to false — the same guard exists in open-source Delta Lake, not only on Databricks. Every RETAIN 0 HOURS horror story crossed that exact line — someone disabled the guard to 'save storage faster.' The tactic: never vacuum with a custom retention without a dry run first. DRY RUN returns up to 1000 files that would be deleted, so you see the blast radius before you pull the trigger.
-- What would this vacuum actually delete, before it deletes it
VACUUM catalog.schema.sales RETAIN 168 HOURS DRY RUN;
REORG TABLE ... APPLY (PURGE) first — VACUUM alone won't physically purge soft-deleted rows).Recommended learning: Databricks docs: VACUUM
A team watched storage costs climb on their CDC-fed sales table — months of upserts had left thousands of superseded parquet files. The fix seemed obvious: a nightly job running VACUUM sales RETAIN 24 HOURS. When Delta's safety check refused, someone disabled it — 'we don't time travel, why keep the files?' Storage dropped 40% overnight. Two weeks later, the quarterly audit asked for the table VERSION AS OF a version from last month, and a downstream incremental reader failed the same day. DESCRIBE HISTORY still listed the versions — the transaction log was untouched — but every parquet file behind them was gone. Nothing to restore from.
Search your job definitions for VACUUM with RETAIN under 168 HOURS, and confirm the safety check is still on everywhere:
spark.conf.get("spark.databricks.delta.retentionDurationCheck.enabled") # expect "true"
Don't lower retention where storage is cheap — raise it on tables with audit or incremental readers, per table:
-- Keep a month of recoverable history on this table
ALTER TABLE catalog.schema.sales
SET TBLPROPERTIES ('delta.deletedFileRetentionDuration' = '30 days');
If predictive optimization is enabled, Databricks already runs VACUUM automatically — but it uses your table's configured delta.deletedFileRetentionDuration (7-day default), not a fixed 7 days. Raising the property to 30 days in step 2 extends the automatic window too, so set it before relying on auto-maintenance. Setting it below 7 days won't shorten auto-cleanup: predictive optimization keeps a 7-day minimum when it runs VACUUM FULL. And it only covers Unity Catalog managed tables (Premium plan or above, Databricks Runtime 12.2 LTS and above) — external tables still need a manual VACUUM job.
SHOW TBLPROPERTIES catalog.schema.sales ('delta.deletedFileRetentionDuration'). 2) Confirm the guard is on: spark.conf.get("spark.databricks.delta.retentionDurationCheck.enabled") should return "true". 3) Run DESCRIBE HISTORY and map the versions your audits and incremental readers need against the floor — every one must sit comfortably inside it. 4) DRY RUN last: it should list nothing unexpected. For predictive-optimization tables, also check DESCRIBE TABLE EXTENDED ... AS JSON (predictive_optimization_evaluations) or the system.storage.predictive_optimization_operations_history system table to confirm VACUUM actually ran.Recommended learning: continue with the site's Recommended learning section.
The version is still in the log. The files it needs are not.
The files are gone, the log isn't. DESCRIBE HISTORY reads the transaction log, which VACUUM never touches (log files keep a separate 30-day default). Time travel is different: it needs the old parquet files physically present. Your version entry survives; the data it points to was deleted — that's why the version is listed but the query fails.
RESTORE can't bring them back. RESTORE TABLE rewinds the table's metadata pointer to an older version, but it cannot reconstruct parquet files that were already deleted. Vacuumed files are unrecoverable unless you have a storage-level backup or snapshot taken before the vacuum.
Prevention beats recovery. Keep 168 hours as the production floor; raise delta.deletedFileRetentionDuration on tables with audit or incremental readers; never disable retentionDurationCheck in production; DRY RUN before every custom-retention vacuum.
Recommended learning: Databricks docs: VACUUM
Applies to: Delta Lake tables on Databricks. The retention-duration safety check exists in both Databricks and open-source Delta Lake (the same checkRetentionPeriodSafety guard in VacuumCommand, disabled the same way with spark.databricks.delta.retentionDurationCheck.enabled=false). Unity Catalog managed-table VACUUM semantics: Databricks Runtime 13.3 LTS and above; the deletedFileRetentionDuration table property: Databricks Runtime 18.0 and above. Predictive optimization: Unity Catalog managed tables only, Premium plan or above, Databricks Runtime 12.2 LTS and above.
Last verified against Databricks docs: September 24, 2026.
Corrections: Sep 24, 2026 — labeled the walkthrough an illustrative scenario; corrected the predictive-optimization explanation (automatic VACUUM uses the table's configured retention, 7-day default with a 7-day minimum); strengthened validation steps; Sep 24, 2026 — corrected the open-source Delta Lake claim (the retention safety check exists in OSS Delta too: same guard, same config flag); explicitly labeled all walkthrough figures illustrative.
Issues, newest first.
Contact: sbogale@sb9tech.com
Lakehouse Digest is a short, practical newsletter for Databricks engineers, published by the Lakehouse Digest team. Each issue delivers one tactic to try, one production pattern to understand, and one hard developer question answered with code and primary-source links. It is an independent publication and is not affiliated with Databricks, Inc.
Topic-led learning paths for readers who want to turn this issue’s tactics into repeatable Databricks practice.
Strengthen the platform basics behind notebooks, jobs, data workflows, and collaborative development.
Browse DataCamp Databricks courses →The official guide behind this issue: retention thresholds, the safety check, and what VACUUM deletes.
Read the Databricks docs →Pipelines, orchestration, and streaming practice that turn this issue's tactics into repeatable habits.
Browse DataCamp data engineering →Partner links: we may earn a commission if you enroll through these recommendations, at no extra cost to you.
A technical audience of Databricks engineers, reading implementation notes they can test the same day.
Launch inventory is one clearly labeled, problem-first placement per issue — built for products that help data teams build, govern, observe, or ship more reliably.
Sponsor Lakehouse Digest →