What is Delta Lake in Databricks? Delta Lake is an open source storage layer that adds reliability to files in a data lake. It stores data as Parquet files together with a transaction log, which gives you ACID transactions, schema enforcement, time travel and efficient updates and deletes on cloud storage. It is the default table format in Databricks and the foundation of the lakehouse. This guide explains how Delta Lake works, the transaction log, common operations such as MERGE, OPTIMIZE and VACUUM, how schema evolution and time travel behave, performance features and the mistakes that cause trouble. Features change by release, so confirm details in current documentation.
Short answer: Delta Lake turns files on cloud storage into reliable tables by adding a transaction log. Use it for ACID writes, MERGE-based upserts, time travel and schema control, and maintain tables with OPTIMIZE and VACUUM.
What is Delta Lake?
A plain data lake stores files with no guarantees. Two jobs writing at once can corrupt a dataset, a failed job can leave half-written data and there is no easy way to update a single row. Delta Lake solves this by recording every change in an ordered transaction log stored next to the data. Readers use the log to see a consistent snapshot, and writers commit changes atomically. It is central to the lakehouse design used by Databricks.

How the transaction log works
- Each table has a log folder that records commits as ordered JSON files, with periodic checkpoints.
- A commit lists the data files added or removed, so a reader can rebuild the table state at any version.
- Concurrent writers use optimistic concurrency, and conflicting changes are detected rather than silently merged.
- Data files are immutable Parquet files. An update writes new files and marks the old ones as removed.
Because the history is in the log, time travel and audit are natural outcomes, not extra systems.
Key capabilities
| Capability | What it gives you |
|---|---|
| ACID transactions | Reliable writes with no partial results |
| Schema enforcement | Writes that do not match the table schema are rejected |
| Schema evolution | Controlled addition of columns when enabled |
| MERGE, UPDATE and DELETE | Row level changes for upserts and corrections |
| Time travel | Query earlier versions by number or timestamp |
| Change data feed | Row level changes exposed for downstream use |
| Unified batch and streaming | One table as both a source and a sink |
These make Delta suitable for pipelines that need correctness, such as change data capture loads and slowly changing dimensions.
Common operations
-- upsert changes into a table
MERGE INTO silver.customers t
USING staged.customers s ON t.id = s.id
WHEN MATCHED THEN UPDATE SET *
WHEN NOT MATCHED THEN INSERT *;
-- compact small files
OPTIMIZE silver.customers;
-- query an earlier version
SELECT * FROM silver.customers VERSION AS OF 12;
-- remove old unused files
VACUUM silver.customers;Syntax and options evolve, so check current documentation before using these in production.
Performance features
| Feature | Purpose | Note |
|---|---|---|
| OPTIMIZE | Compacts many small files into larger ones | Run on a schedule for frequently written tables |
| Z-ordering or liquid clustering | Co-locates related data to skip files during queries | Choose columns used in filters; check current recommendations |
| Data skipping | Uses file statistics to avoid reading irrelevant files | Works best with sensible clustering |
| Deletion vectors | Mark rows deleted without rewriting whole files | Speeds up updates and deletes where enabled |
| Auto compaction | Reduces small files during writes | Check settings for your workload |
Small files are the most common cause of slow queries on lake tables, so plan compaction from the start.
Time travel and VACUUM
Time travel lets you query or restore earlier table versions as long as the underlying files still exist. VACUUM removes files no longer referenced by the log and older than a retention threshold, which is seven days by default. Shortening the threshold saves storage but reduces how far back you can travel and can break long running readers, so change it carefully. Keep retention aligned with your recovery requirements.
How to design a Delta table
- Choose the grain. Decide what one row represents and the key that identifies it.
- Define the schema. Use explicit types and avoid free-form columns where possible.
- Choose clustering or partitioning. Use clustering on filter columns, and partition only very large tables by low cardinality columns such as date.
- Set properties. Enable features such as change data feed or deletion vectors where they help.
- Plan maintenance. Schedule OPTIMIZE and VACUUM and monitor file counts.
- Test recovery. Practise reading an earlier version and restoring it.
Best practices
- Choose primary keys and merge conditions carefully, since a poor MERGE condition can duplicate or overwrite rows.
- Enable change data feed on tables that feed downstream consumers or audits, instead of rebuilding them each day.
- Keep table properties in code so every environment is configured the same way.
- Monitor the number and size of files per table, and alert when averages fall far below the target size.
- Use constraints and expectations for key quality rules such as not null and valid ranges.
- Separate raw, cleaned and curated tables so corrections never rewrite raw history.
Streaming with Delta
A Delta table can be both a streaming source and a sink, so the same table serves batch queries and continuous pipelines. Structured Streaming reads new commits and writes micro-batches with exactly-once semantics when checkpoints are used correctly. Use a trigger that matches the latency need, such as continuous micro-batches or a scheduled availableNow run that processes new data and stops. Keep each streaming query on its own checkpoint location and never share it between queries. When you change a query in incompatible ways, plan a controlled reprocessing of the data.
Reading a table history
The table history shows each commit with its operation, user, time and metrics such as rows written. Use it to answer questions like who changed this table and when, how many rows did the merge touch and which version was current when a report was built. Pair it with the version number in a time travel query to reproduce an old report exactly, which is valuable for audits and for explaining differences between two reports that were run at different times.
Common mistakes
- Partitioning on a high cardinality column, creating thousands of tiny partitions.
- Never running OPTIMIZE, so streaming writes leave millions of small files.
- Running VACUUM with a very short retention and breaking readers or time travel.
- Allowing schema evolution without review, so bad upstream columns reach production tables.
- Treating Delta tables like normal files and editing them outside the table API.
A worked example
A retailer streams point-of-sale events into a bronze Delta table. A daily job merges clean records into a silver table using MERGE, which handles late and corrected transactions. After a month, queries slowed because streaming left many small files. Scheduling OPTIMIZE nightly and clustering on store and date cut query time sharply. When a bad promotion code load corrupted prices, the team restored the previous table version and replayed the corrected feed.
The example is illustrative, but the pattern of merge, compact and restore is typical.
Governance and support
Register Delta tables in Unity Catalog so access, lineage and audit work consistently. Our data analytics service designs lakehouse tables and maintenance routines, and our data governance service covers retention and policy decisions.
Key takeaways
- Delta Lake adds a transaction log to files on cloud storage.
- It gives ACID writes, schema control, MERGE and time travel.
- Compact small files with OPTIMIZE and plan clustering.
- VACUUM removes old files, so set retention carefully.
- Register tables in a governed catalog.
Quick glossary
| Term | Meaning |
|---|---|
| Transaction log | Ordered record of table changes |
| ACID | Atomic, consistent, isolated and durable transactions |
| MERGE | Upsert command that matches rows |
| OPTIMIZE | Command that compacts small files |
| VACUUM | Command that removes unreferenced files |
Read next: BigQuery vs Snowflake: Which Cloud Data Platform? · BigQuery Streaming Inserts: Real-Time Ingestion Guide · BigQuery Access Control: IAM, Policy Tags and Row Security
Frequently asked questions
What is Delta Lake?
It is an open source storage layer that adds ACID transactions, schema control and time travel to files on cloud storage.
How does Delta Lake store data?
As Parquet files plus an ordered transaction log that records each commit.
What does OPTIMIZE do?
It compacts many small files into fewer larger ones to speed up reads.
What does VACUUM do?
It deletes data files that are no longer referenced and older than the retention threshold.
Can I query old versions of a table?
Yes, with time travel by version or timestamp while files still exist.
Is Delta Lake only for Databricks?
No. It is open source, though Databricks provides tight integration and additional features.
How do I do upserts?
Use MERGE INTO to match rows and update or insert them in one atomic operation.
Should I partition every Delta table?
No. Partition only very large tables by low cardinality columns and consider clustering for filter columns.
