Databricks · Beginner
How does the Delta Lake transaction log work?
By Anurag Pandey, Lead Data Engineer ·
The short answer
The _delta_log folder holds an ordered series of JSON commit files, each listing the data files added or removed in one transaction, plus periodic Parquet checkpoints. Readers rebuild the current table from the latest checkpoint and the commits after it.
Opens this question on SpinTheMic. Start without signing up; sign in free for an AI report card.
Say it like this
About 60 seconds out loud. Use it as a model, then put it in your own words.
Every Delta table has a _delta_log folder next to its data files. Each successful write creates a new numbered JSON file in that folder, a commit, that records what changed: which Parquet files were added, which were removed, and any change to the schema or table properties. A commit is all or nothing, so readers see either the whole change or none of it. To know the current state of the table, a reader replays the log. Because replaying thousands of small JSON files would be slow, Delta regularly writes a checkpoint in Parquet that summarises the state up to that point. When two writers commit at the same time, Delta uses optimistic concurrency control: one commits first, and the other checks whether its changes conflict. If they do, it fails with a concurrent modification exception. Time travel simply reads the table as of an older commit.
What interviewers look for
- You describe numbered JSON commits with add and remove actions.
- You explain checkpoints and why they exist.
- You mention optimistic concurrency for concurrent writers.
Common mistakes
- Saying old data files are deleted when rows change. They are marked removed in the log and deleted later by VACUUM.
- Forgetting checkpoints, which keep reads fast on busy tables.
- Saying Delta locks the table during writes.
Follow-up questions to expect
- 1What happens when two jobs update the same partition at once?
- 2How long can you time travel, and what limits it?
- 3What does VACUUM remove?
Opens this question on SpinTheMic. Start without signing up; sign in free for an AI report card.