Data Engineering · Chapter 10 · ~15 min · Advanced
Data Lakes, Warehouses & Lakehouses: Delta Lake & Iceberg
Understand the convergence of storage and compute: file formats meet database transactions with Apache Iceberg and Delta Lake. ACID guarantees on S3 object storage, time travel, compaction, and partition evolution.
- Trace the architectural evolution from Warehouses to Data Lakes to Open Lakehouses
- Understand ACID transaction logs on object storage (Delta Log and Iceberg Metadata Trees)
- Execute Time Travel queries and schema evolution without physical table rewrites
- Implement table optimization strategies: file compaction (bin-packing) and Z-Ordering
Data Lakes, Warehouses & Lakehouses: Delta Lake & Iceberg: learn it visually
Understand the convergence of storage and compute: file formats meet database transactions with Apache Iceberg and Delta Lake. ACID guarantees on S3 object storage, time travel, compaction, and partition evolution.
1Everyday Intuition: The Filing Cabinet with Git Version Control
To understand the Lakehouse architecture, compare the three historical storage paradigms:
The Polished Mahogany Cabinet
Proprietary, highly structured, lightning-fast SQL queries, but extraordinarily expensive and incapable of storing unstructured video, audio, or raw semi-structured JSON payloads.
The Giant Cardboard Storage Room
Cheap object storage (S3/GCS) holding unlimited petabytes. But without transactions, it quickly turned into a "data swamp": unindexed files, partial write crashes, and zero ACID guarantees.
Git Commit Log on S3
Apache Iceberg and Delta Lake marry cheap S3 storage with a formal ACID transaction log. Every commit is atomic, tables support historical time-travel, and multiple engines (Spark, Trino, DuckDB) share one open format.
Why can raw cloud object storage (Amazon S3 / Google Cloud Storage) not provide database ACID guarantees on its own?
2Under the Hood: Apache Iceberg Metadata Architecture
In Apache Iceberg, the "table" is not a directory of files; it is an immutable metadata snapshot tree:
1. Iceberg Catalog
Tracks the current metadata pointer for each table (e.g. v4.metadata.json). When an atomic transaction commits, the catalog updates its pointer via Optimistic Concurrency Control (OCC).
2. Manifest List
Captures a snapshot in time. Lists all manifest files active in that version along with partition field summaries.
3. Manifest Files
Store direct pointers to physical data files (Parquet/ORC) and record exact column statistics (min/max bounds, null counts) for ultra-fast query predicate pushdown.
Wrong idea: Encode partition dates into physical S3 directory paths
Organizing files as '/year=2026/month=11/day=20/'. When users query 'WHERE event_time > ...', query engines scan all directories unless users also remember to explicitly filter the physical partition string.
Real system: Iceberg Hidden Partitioning decouples logical transforms from layout
Iceberg applies partition transforms (e.g. days(event_time)) directly in the metadata catalog. Users write standard queries and Iceberg prunes files automatically.
How do Delta Lake and Apache Iceberg execute 'Time Travel' historical queries without duplicating entire datasets?
3Hands-On: Test Snapshots, Bin-Packing & VACUUM
Interact with the Lakehouse metadata tree below. Experience how historical snapshots preserve time-travel, run bin-packing compaction (OPTIMIZE) to eliminate the small file problem, and test safe VACUUM policies:
Lakehouse ACID Snapshot & Compaction Engine
Explore immutable snapshot trees, execute time-travel queries across historical manifests, and simulate bin-packing compaction.
Contains snapshot partition boundaries & manifests.
280 Tombstones (Historical)
What risk occurs if you execute VACUUM with a retention threshold of 0 hours on a production Lakehouse table?
4Bug Hunt: Optimize a Fragmented Lakehouse Table
The maintenance script below leaves 45,000 tiny files uncompacted, risks production downtime by executing a dangerous zero-hour vacuum, and performs unpartitioned table scans. Fix all three issues:
🎯 Find and fix the bugs in the code above, then press Run & verify to test your solution.
Need a hint?
- Call
delta_table.optimize().executeCompaction()to bin-pack small files. - Replace
vacuum(0)with safe 7-day retentionvacuum(168). - Add time-travel options or partition filtering to the read query.
5Recap
- Open Lakehouses (Apache Iceberg, Delta Lake) combine the low storage cost of cloud object storage with ACID database transactions.
- Immutable Transaction Logs provide snapshot isolation, zero dirty reads under concurrent writes, and deterministic Time Travel queries.
- Hidden Partitioning decouples user queries from physical S3 directory paths, allowing partition schemes to evolve without rewrites.
- File Compaction (Bin-Packing) consolidates streaming micro-batch files into 128MB chunks, while VACUUM cleans up expired tombstones.
Ready for Chapter 11? Mark this chapter as complete to proceed: