Delta Lake Essentials
Test what you know about Delta Lake tables: the transaction log, concurrent writes, time travel and VACUUM, MERGE, schema enforcement and evolution, the change data feed, deletion vectors, liquid clustering and constraints.
Question 1 of 12
Question 1
What makes a write to a Delta table atomic?
Not this time. Data files are written first, then one new entry is committed to the transaction log listing every file the write added. Readers only see files the log marks as valid, so a failed write leaves no visible change.
Question 2
By default on Databricks, what isolation do reads and writes of a Delta table get?
Not this time. Databricks gives snapshot isolation to reads and write-serializable isolation to writes by default, through optimistic concurrency control: no locks, so no deadlocks.
Question 3
You run VACUUM on a Delta table with the default settings. What do you lose?
Not this time. VACUUM deletes data files that are no longer in the latest table state and were removed more than 7 days ago by default. After it runs, you can no longer time travel to a version older than that retention period.
Question 4
Which query reads a Delta table as it was at version 123?
Not this time. Time travel adds VERSION AS OF or TIMESTAMP AS OF after the table name. In Python, the versionAsOf and timestampAsOf reader options do the same.
Question 5
DESCRIBE HISTORY shows 30 days of operations. Why can time travel to a version from 20 days ago still fail?
Not this time. History and time travel follow different settings. History is kept for logRetentionDuration, 30 days by default, while the old data files are kept only for deletedFileRetentionDuration, 7 days by default, and VACUUM removes them after that. Use only the last 7 days for time travel unless you raise both.
Question 6
A MERGE INTO fails because more than one source row matched the same target row. What is the fix?
Not this time. Only a single source row can match a given target row. Remove the duplicates from the source first, for example by keeping the latest row for each key, then merge.
Question 7
A nightly full extract should also delete target rows that are no longer in the source. Which MERGE clause does that?
Not this time. WHEN NOT MATCHED BY SOURCE can UPDATE or DELETE target rows that have no matching source row. Databricks recommends a condition on it so the whole target is not rewritten.
Question 8
An INSERT into a Delta table names a column the table does not have. What happens by default?
Not this time. Delta enforces the schema on write: every inserted column must exist in the target table, so the INSERT fails with an unresolved column error. To add the column on purpose, use schema evolution (INSERT WITH SCHEMA EVOLUTION, or the mergeSchema option).
Question 9
In the change data feed of a Delta table, what does an update produce?
Not this time. The change data feed adds _change_type, _commit_version and _commit_timestamp. An update appears as 2 rows: update_preimage, the row before the change, and update_postimage, the row after.
Question 10
What do deletion vectors change when you delete one row from a large Delta table?
Not this time. Without deletion vectors, changing one row rewrites the whole Parquet file that holds it. With them, the row is marked as removed in metadata, and reads apply the marks at query time. The file is rewritten later, by OPTIMIZE, REORG TABLE ... APPLY (PURGE) or auto-compaction.
Question 11
Why does Databricks recommend liquid clustering over partitioning for new tables?
Not this time. Liquid clustering replaces partitioning and ZORDER. Its clustering keys can be changed without rewriting existing data, it avoids over-partitioning, and it allows row-level concurrency, which reduces write conflicts.
Question 12
You add a CHECK constraint (amount > 0) to a table that already holds a row with amount = -5. What happens?
Not this time. ALTER TABLE ADD CONSTRAINT verifies that all existing rows satisfy the constraint before adding it, so the command fails. Once a constraint exists, any transaction that violates it fails with an error.
Sources
Where each fact comes from
- 1What are ACID guarantees on Databricks?
- 2Isolation levels and write conflicts
- 3VACUUM
- 4Work with table history
- 5Upsert into a Delta Lake table using merge
- 6Schema enforcement
- 7Update table schema
- 8Use Delta Lake change data feed on Databricks
- 9Deletion vectors in Databricks
- 10Use liquid clustering for tables
- 11Optimize data file layout
- 12Constraints on Databricks