Delta Lake explained: log, ACID, time travel
Delta Lake is an open table format that puts a transaction log on top of ordinary Parquet files in cloud storage, which gives a data lake the behaviour of a database table: atomic writes, consistent reads, schema checks and history. The decision rule for exams: if a scenario needs updates, deletes, merges, safe concurrent writers, or the ability to read an earlier state of the data, the answer is a Delta table, not plain Parquet, CSV or JSON files.
Layer one: files that never change
A Delta table is a folder. Inside are Parquet data files and a subfolder called _delta_log. Data files are immutable: Delta never edits a Parquet file in place. An UPDATE writes new files containing the changed rows and marks the old files as removed. Every behaviour below follows from that one design choice.
Layer two: the transaction log
The log is an ordered series of small commit files, one per successful write. Each commit lists actions such as “add this data file” and “remove that data file”. The current state of the table is whatever you get by replaying the log from the start (the log is periodically summarised into checkpoint files so readers do not replay everything). The format is public: the Delta transaction log protocol is an open specification, which is why several engines can read the same table.
A write is not visible until its commit file lands in the log. That gives you:
- Atomicity. A job that fails halfway leaves orphan data files that no commit references, so readers never see half a write.
- Consistency and isolation. A reader works from one snapshot, the table as of a log version, even while writers keep committing.
- Concurrency by optimism. Writers do not lock. Before committing, Delta checks whether another commit since the snapshot conflicts with the staged change. If it does, the write fails with a concurrent-modification exception rather than corrupting the table (Delta documentation, concurrency control). Appends from two jobs usually coexist; two jobs rewriting the same files do not.
- Durability. The commit is stored in the same cloud storage as the data.
Together that is ACID. Schema enforcement is part of the same story: a write whose columns do not match the table schema is rejected unless schema evolution is deliberately enabled.
A worked example: four commits
An orders table receives these operations in order:
| Version | Operation | What the log records |
|---|---|---|
| 0 | CREATE TABLE with an initial load | adds file A |
| 1 | INSERT new orders | adds file B |
| 2 | UPDATE one order’s status | removes file A, adds file C (A’s rows plus the fix) |
| 3 | DELETE cancelled orders | removes file B, adds file D |
Version 3 reads only files C and D. Files A and B still exist on storage, which is why this works:
SELECT * FROM orders VERSION AS OF 1;
SELECT * FROM orders TIMESTAMP AS OF '2026-10-01';
DESCRIBE HISTORY orders;
The table describes the classic copy-on-write behaviour. With deletion vectors enabled (an option on Databricks whose default for new tables varies by workspace and region), an UPDATE or DELETE can mark rows as removed in a small side file instead of rewriting the whole data file; old versions stay readable in the same way.
Version 1 resolves to files A and B. That is time travel: reading an old snapshot costs nothing extra, because the old files were never deleted. DESCRIBE HISTORY lists the versions, and RESTORE rolls a table back to one.
OPTIMIZE and VACUUM do opposite jobs
Because every small write adds files, tables drift into thousands of tiny files and reads slow down.
| OPTIMIZE | VACUUM | |
|---|---|---|
| Purpose | Speed up reads | Free storage |
| What it does | Rewrites many small files into fewer larger ones (compaction), optionally clustering data | Physically deletes data files that no version inside the retention window references |
| Effect on time travel | None; it only adds a commit | Removes the ability to read versions older than the retention period |
| Default window | Not applicable | 7 days for data files |
Bin-packing OPTIMIZE is idempotent: a second run on the same data has no effect, according to Databricks documentation. On Databricks, predictive optimization can run OPTIMIZE and VACUUM automatically for Unity Catalog managed tables; otherwise you schedule it. Note the two separate retention settings: history in the log is kept for 30 days by default (delta.logRetentionDuration), while deleted data files must age 7 days (delta.deletedFileRetentionDuration) before VACUUM may remove them. Time travel reaches back only as far as both allow, so vacuuming with a short retention breaks it. Databricks recommends keeping at least 7 days, partly because a shorter window can delete files that a long-running job still needs.
Which exams test this
| Exam | How it appears | On this site |
|---|---|---|
| Databricks Data Engineer Associate | Databricks Intelligence Platform (6%): Delta Lake as a core platform component; ingestion objectives land data in Unity Catalog-governed Delta tables, and Troubleshooting, Monitoring and Optimization (10%) adds Liquid Clustering and predictive optimization | Ingestion and platform, Transformation and modeling |
| Databricks Data Engineer Professional | Outline from October 9, 2026, Cost and Performance Optimization (15%): pick a Delta optimization technique (deletion vectors, Liquid Clustering, CLUSTER BY AUTO), use Change Data Feed for incremental processing; Data Security and Compliance (8%) adds purging data with Delta Lake features to meet deletion policies | Databricks DE Professional: cost and performance |
| Databricks Data Analyst Associate | Delta Lake as a platform component (Section 1, 11%), querying earlier versions with time travel (Section 4, 20%), and using table history to audit and compare results (Section 5, 15%) | Platform and data |
| DP-700 | Monitor and optimize an analytics solution (30–35%): optimize a lakehouse table, whose tables are Delta, which brings in OPTIMIZE and VACUUM | Monitor and optimize |
| DP-750 | Prepare and process data (30–35%): choose Delta among table formats, enforce schema and manage schema drift, load with merge; Deploy and maintain (30–35%): optimize Delta tables with OPTIMIZE and VACUUM | Prepare and process data, Deploy and maintain pipelines |
How exam questions are built around Delta
The stem usually describes a symptom and asks for the one feature that fixes it. Read the symptom first:
- “Many small files, slow queries” points to OPTIMIZE. “Storage cost keeps growing” points to VACUUM. Candidates swap them because both touch files.
- “Recover the table as it was before a bad update” points to time travel or RESTORE, and the follow-up trap is a VACUUM that already ran.
- “Two jobs write at once and one fails” is expected behaviour from optimistic concurrency, not a bug.
- “Source added a column and the write failed” is schema enforcement working. The fix is deliberate schema evolution, not disabling checks.
- “Apply inserts, updates and deletes from a feed in one statement” is MERGE.
Constraint words that decide it: recover, audit a previous state (time travel), reduce small files (OPTIMIZE), reclaim storage (VACUUM), without copying data (the open format and shared log).
Practice questions
Question 1. A Delta table receives frequent small appends from a streaming job. Dashboard queries on the table have become slower over several weeks, and the table now has a very large number of small data files. What should the data engineer run to improve read performance?
- A. Run VACUUM with a retention of 0 hours
- B. Run OPTIMIZE on the table
- C. Query the table with VERSION AS OF
- D. Disable schema enforcement
Show answer
Answer: B
OPTIMIZE compacts many small files into fewer larger ones, which is what slows reads here. VACUUM deletes unreferenced old files to save storage and does not compact the files the current version uses. Time travel is a way to read old versions, not a tuning step. Disabling schema enforcement has no effect on file count.
Question 2. On Monday an incorrect UPDATE changed thousands of rows in a Delta table. On Wednesday the team wants to query the table as it was before the update. VACUUM runs weekly with the default 7-day retention and no table properties were changed. What is true?
- A. The previous data is lost because UPDATE overwrote the files in place
- B. The table must be rebuilt from the original source system
- C. Only a restore from a storage backup can recover it
- D. The earlier version can still be queried with time travel
Show answer
Answer: D
With default settings, files removed by Monday’s update are still within the 7-day deletion window, and the log keeps 30 days of history, so VERSION AS OF or TIMESTAMP AS OF can read the earlier state. The old data is not gone: updates write new files and keep old ones until VACUUM removes them. A backup restore is unnecessary. Time travel does not need the table to be rebuilt from the source.
Go deeper
- What is Delta Lake in Databricks?: transaction log, ACID and the default format.
- Delta Lake: remove unused data files with VACUUM and OPTIMIZE: retention thresholds and compaction.
- Delta transaction log protocol: the open specification.
- Related topic: DAX basics for the reporting layer on top, and How to study for certification exams for planning your revision.