The previous lesson left DataCorp facing a dilemma: it has a data lake in an open format and needs, for its consumption zone, the transactions, performance and governance of a data warehouse, but maintaining two systems means a double copy and double governance that two people should not have to take on. The data lakehouse is the architecture that was born to solve exactly that problem: bringing the qualities of the warehouse to the lake's storage, instead of copying the data from one to the other.
This lesson explains what a lakehouse is and the technical piece that makes it possible: open table formats (Delta Lake, Apache Iceberg and Apache Hudi). We will see how they work internally, what they provide, how they differ and how they are used, with an example in SQL. DataCorp will then make the decision deferred since ADR-004: ADR-015 sets the table format and the type of analytical engine, and with it the architecture stops being a sum of pieces and finally gets a name and an overall shape.
What a lakehouse is
A data lakehouse is an architecture that offers the data management and performance of a data warehouse (transactions, schema, updates, fast queries, governance) directly on the cheap, open storage of a data lake. The term became widespread in 2020.
The central idea is simple: a single copy of the data, in open files on object storage, that serves BI, SQL and data science at the same time. The hop from the lake to the warehouse disappears and, with it, the double copy.
Two pieces make it possible:
- An open table format, which turns a set of files into a table with guarantees.
- An MPP query engine able to read that format with performance close to that of a warehouse.
Open table formats: how they work
Let's recall the problem from lesson 06-02: a "table" in a lake is a folder with Parquet files. Nothing indicates which files make up the table at a given moment: they are simply whichever ones are in the folder. If a process is writing, whoever is reading sees half of it.
A table format adds a metadata layer to the data files that answers a single question: exactly which files make up the table right now?
flowchart TB
C["Catalog<br/>consumption.fact_sales → current snapshot"] --> S3
subgraph MD["Table metadata (transaction log)"]
S1["Snapshot 1<br/>files A, B"]
S2["Snapshot 2<br/>files A, B, C"]
S3["Snapshot 3<br/>files A, C, D"]
S1 --> S2 --> S3
end
subgraph DA["Data files (Parquet, immutable)"]
A["A.parquet"]
B["B.parquet"]
Cf["C.parquet"]
D["D.parquet"]
end
S3 -.-> A
S3 -.-> Cf
S3 -.-> D
How it works comes down to four rules:
- Data files are immutable. A Parquet file is never modified; new files are only ever added.
- Each change creates a snapshot: a list of the files that make up the table after that change. In the diagram, snapshot 2 adds file C (an insert); snapshot 3 replaces B with D (an update: D contains the rows of B, including the modified ones).
- The commit is atomic. The change only exists once the transaction log points to the new snapshot. That step is a single indivisible operation: either it happens or it does not.
- Readers follow the log, not the folder. Whoever starts reading at snapshot 2 sees A, B and C until they finish, even if snapshot 3 is committed in the meantime.
All the properties in the next section derive from these four rules. Note that file B is not deleted when snapshot 3 is created: it remains in storage, which is why the table can be queried "as it was before". It only disappears when a maintenance process removes the old snapshots.
Besides the list of files, the metadata stores the schema, the definition of the partitions and per-file statistics (minimum and maximum of each column), which let the engine discard files without opening them.
What they provide
| Capability | What it means | Why DataCorp needs it |
|---|---|---|
| ACID transactions | A load is seen complete or not at all | The micro-batches write every 10 and 15 minutes while queries are running |
| Concurrent reads and writes | Readers are not blocked; two conflicting writers are detected and one retries | A manual reload coincides with the nightly load |
| MERGE, updates and deletes | SQL statements on specific rows | Upsert of fact_sales by line_id; change of order_status |
| Deletion for the right to erasure | DELETE of a customer, and physical removal when the snapshots expire |
Erasure procedure of lesson 03-04 |
| Schema evolution | Adding, renaming or dropping columns without rewriting the data | The new orders.campaign_code and updated_at |
| Partition evolution | Changing the partitioning without moving the old data | Switching a table from monthly to daily partitions if it grows |
| Time travel | Querying the table at an earlier snapshot or date | Auditing a figure; undoing a faulty load |
| Compaction | Merging many small files into a few large ones, transactionally | Remedy for the small files problem of the micro-batches (02-06) |
| Schema validation | Rejecting a write that does not respect the columns and types | Schema on write in the cleansed and consumption zones |
Warning. Time travel has a legal consequence: a deleted row still exists in the earlier snapshots until they expire and their files are removed. The snapshot retention period must be set with the data protection officer, so that the effective erasure is completed within the legal deadline.
Delta Lake, Iceberg and Hudi
The three formats solve the same problem with similar mechanisms. All three store the data in Parquet.
| Delta Lake | Apache Iceberg | Apache Hudi | |
|---|---|---|---|
| Origin | Databricks (2019); Linux Foundation project | Netflix (2017); Apache Software Foundation project | Uber (2016); Apache Software Foundation project |
| Metadata | Ordered log of JSON files in _delta_log/, with checkpoints |
Tree of metadata files and manifests; the catalog points to the current one | Timeline of actions in .hoodie/ |
| Strength | Integration with Spark and Databricks; simplicity | Neutrality: open specification and the broadest support across engines | Frequent updates and near-continuous incremental ingestion |
| Partitioning | Classic, by columns; automatic clustering in recent versions | Hidden (through transforms such as month(sales_date)) and evolvable |
Classic, by columns |
| Engines | Spark, Databricks, Microsoft Fabric, Trino, Flink, DuckDB | Spark, Trino, Flink, Snowflake, BigQuery, Athena, Redshift, DuckDB, among others | Spark, Flink, Trino, Athena |
| Best fit when | The platform revolves around Spark, Databricks or Fabric | You want several engines and no dependence on one vendor | There are many updates by key in a near-continuous stream |
Two observations:
- They are converging. The functional differences have narrowed a great deal, and there are mechanisms that make a table written in one format readable as another. The choice is less of a commitment than it was a few years ago.
- The practical criterion is the ecosystem: which format the engine and the tools you are going to use read and write natively.
Iceberg's hidden partitioning deserves an explanation. With classic partitioning (lesson 02-06), the partition is a visible column (month=2026-11) and the user has to filter by it for pruning to happen. With hidden partitioning, the table declares that it is partitioned by month(business_date); the user filters by business_date, and the engine works out which partitions to read. There is no partition column to maintain or to remember.
Catalogs and engines: the same data, several engines
For the atomic commit step to work, someone has to keep the pointer to the current snapshot of each table. That is the role of the technical catalog (the metastore of lesson 06-02, now with one more function): it associates each table name with its current metadata and arbitrates between writers.
Because the catalog and the format are open, several engines can work on the same tables, each one for what it does best:
flowchart TB
M1["Analytical SQL engine<br/>(BI and transformations)"] --> CAT
M2["DuckDB / Python<br/>(micro-batches, notebooks)"] --> CAT
M3["Spark<br/>(if it were ever needed)"] --> CAT
CAT["Technical catalog"] --> T[("Tables in an open format<br/>on object storage")]
This is the decisive difference from a classic warehouse, where the data is only accessible through its engine. Here, changing engines does not force you to migrate the data. Managed catalogs also add permissions per table and, in many cases, per column and row, which solves the coarse governance of the lake.
Medallion architecture on a lakehouse
The organization into zones from lesson 06-02 is kept, but now each zone can have table guarantees:
| Zone | Format | Guarantees |
|---|---|---|
| Bronze (raw) | Original files, or append-only tables | Immutability; it is the archive |
| Silver (cleansed) | Tables in an open format | ACID, validated schema, MERGE, deduplication |
| Gold (consumption) | Tables in an open format, dimensional model and aggregates | ACID, performance for BI, fine-grained permissions |
The dimensional modeling of lesson 02-05 and the dbt transformations of 04-02 do not change: what changes is what lies beneath the tables.
Practical example: create, merge and travel in time
We will use SQL with Iceberg tables, in the syntax of the Trino engine (the one shared, with small variations, by several managed services). The scenario: order 9005, placed by Lucía Ferrer, which was recorded as shipped, is returned.
-- 1. CREATE the cleansed orders table as an Iceberg table.
CREATE TABLE cleansed.orders (
order_id BIGINT,
customer_id BIGINT,
order_date TIMESTAMP(6) WITH TIME ZONE, -- timestamp in UTC
business_date DATE, -- date in Europe/Madrid
status VARCHAR,
total_amount DECIMAL(10, 2),
campaign_code VARCHAR,
load_date DATE
)
WITH (
format = 'PARQUET', -- ADR-004 still applies
partitioning = ARRAY['month(business_date)'], -- hidden, monthly partitioning
location = 'datacorp-data-cleansed/postgres/orders/'
);
-- 2. MERGE: bring in today's extraction (upsert by order_id).
-- 'raw.orders' is the external table over the raw zone.
MERGE INTO cleansed.orders AS tgt
USING (
SELECT * FROM raw.orders
WHERE load_date = DATE '2026-11-18'
) AS src
ON tgt.order_id = src.order_id
WHEN MATCHED AND tgt.status <> src.status THEN
UPDATE SET status = src.status,
load_date = src.load_date
WHEN NOT MATCHED THEN
INSERT (order_id, customer_id, order_date, business_date,
status, total_amount, campaign_code, load_date)
VALUES (src.order_id, src.customer_id, src.order_date,
src.business_date, src.status, src.total_amount,
src.campaign_code, src.load_date);
-- 3. VIEW the history: each operation has created a snapshot.
SELECT snapshot_id, committed_at, operation
FROM cleansed."orders$snapshots"
ORDER BY committed_at;
-- 4. TIME TRAVEL: order 9005 before and after the load.
SELECT status FROM cleansed.orders
FOR TIMESTAMP AS OF TIMESTAMP '2026-11-17 12:00:00 Europe/Madrid'
WHERE order_id = 9005; -- returns: shipped
SELECT status FROM cleansed.orders
WHERE order_id = 9005; -- returns: returnedWhat happens at each step:
- Step 1. The table's metadata is created, with no data.
partitioningdeclares a transform, not a column: queries will filter bybusiness_date. - Step 2. The
MERGEcompares by key. Existing orders whose status has changed are updated; new ones are inserted. Internally, the engine writes new Parquet files with the affected rows and commits one snapshot. If the process fails halfway, nothing is committed and the table stays as it was: the load is idempotent and atomic without writing a single line of code for it. - Step 3. The
$snapshotsmetadata table shows the history: one row per commit, with its date and its type of operation. - Step 4.
FOR TIMESTAMP AS OFreads the snapshot that was current at that moment. It is what makes it possible to answer "what did the dashboard show yesterday?".
The right to erasure and maintenance are handled with the same mechanism:
-- Logical erasure: the customer no longer appears in queries.
DELETE FROM cleansed.customers WHERE customer_id = 2210;
-- Physical erasure: snapshots older than 7 days are removed
-- and, with them, the files that no snapshot references any longer.
ALTER TABLE cleansed.customers EXECUTE expire_snapshots(retention_threshold => '7d');
-- Compaction: merges the small files into large files.
ALTER TABLE cleansed.clickstream_events EXECUTE optimize;With Delta Lake the operations are the same with a different syntax (VERSION AS OF, VACUUM, OPTIMIZE), and there are Python libraries (deltalake, pyiceberg) for performing them without a SQL engine.
Lake, warehouse and lakehouse
| Data lake | Data warehouse | Data lakehouse | |
|---|---|---|---|
| Storage | Objects, open files | Internal to the engine | Objects, open files + table metadata |
| Data types | All | Structured and semi-structured | All (the guarantees, on tabular data) |
| ACID transactions | No | Yes | Yes |
| Updating and deleting | Manual rewrite | SQL | SQL |
| BI performance | Low or uneven | The highest | High; somewhat lower at very low latencies |
| Governance | Per folder | Per table, column and row | Per table and, depending on the catalog, column and row |
| Engines | Several | One | Several |
| Copies of the data | One | Two, if it coexists with a lake | One |
| Vendor lock-in | Low | High | Low for the data; medium for the catalog |
| Table maintenance | Manual | Automatic | It has to be scheduled (or bought as a managed service) |
Limitations and maturity
The lakehouse is neither free nor free of problems:
- Maintenance is your own responsibility. Compacting, expiring snapshots and cleaning up orphaned files has to be scheduled. Without it, tables with frequent writes degrade.
- Startup latency. Opening metadata and files in object storage costs tenths of a second or seconds. For very fast, highly concurrent queries, a warehouse with native storage is still superior.
- Optimistic write concurrency. Two simultaneous writes on the same data do not block each other: one fails and has to retry. It works well with few writers.
- Uneven support. Not all engines implement all the features of each format; reading is very widespread, writing less so.
- The catalog is the new point of dependence. The data is open, but permissions and pointers live in one specific catalog.
- Maturity. The formats are stable and are used in production at large scale, but the ecosystem evolves quickly. It is wise to check the real support with a test before committing.
ADR-015: DataCorp's overall architecture
Marta evaluates the module's three architectures against the requirements that weigh most:
| Alternative | RQ-05 (< 5 s, 10 concurrent) | RQ-12 (≤ €4,000/month) | RQ-13 (2 people) |
|---|---|---|---|
| A. Lake only (Parquet + DuckDB) | No: no concurrency, transactions or fine-grained permissions | Yes, the cheapest | Partly: cheap to operate, but the guarantees would have to be coded |
| B. Lake + classic warehouse | Yes, the best | Yes, but with duplicated compute and storage | No: double copy, double governance, one more load |
| C. Simple lakehouse | Yes, in all likelihood, with aggregate tables; to be validated | Yes: no fixed cost, pay-per-query on a small volume | Yes: one storage, one governance, no servers |
ADR-015: Overall architecture: a simple lakehouse with Apache Iceberg
and a managed serverless SQL engine
Status: accepted Date: 2026-12-14
CONTEXT
ADR-004 deferred the table format and the analytical engine. The
consumption zone needs upsert, atomic loads concurrent with queries, row
erasure, fine-grained permissions and responses in less than 5 s (RQ-05).
The volume is small (2 GB/day), the team is two people (RQ-13) and the
budget is 4,000 EUR/month (RQ-12). ADR-003 requires open formats and
prefers managed or serverless services.
DECISION
1. The platform is a three-zone lakehouse on object storage. There is no
separate warehouse: a single copy of the data.
2. Raw zone: unchanged (ADR-002 and ADR-004). Original files, exposed as
external tables.
3. Cleansed and consumption zones: Apache Iceberg tables, with data in
Parquet + zstd, in their buckets. This extends ADR-004: the partition
criteria are kept (day for the clickstream, month for the rest),
expressed as Iceberg transforms; the root of each table keeps the path
convention, and the file names are now managed by the format.
4. Technical catalog: the provider's managed catalog, compatible with
Iceberg. It holds tables and permissions (roles of ADR-006).
5. Analytical engine: a managed, serverless SQL service, with separation
of storage and compute and pay-per-use, that reads and writes Iceberg
and has a dbt adapter and a Metabase connector. It runs the
transformations (ADR-009) and serves BI (ADR-013). The specific
product is chosen together with the cloud provider, through a proof of
concept (lesson 07-01).
6. Two compute groups: "load" (svc_load) and "query" (people and
svc_bi), with a limit on the data read per query.
7. Python with DuckDB and PyIceberg for the micro-batches and the
notebooks (ADR-011): the same data, another engine.
8. Maintenance: a daily DAG, table_maintenance (22:00), compacts,
expires snapshots older than 7 days and removes orphaned files.
9. The view consumption.v_dim_customer is kept as the masking mechanism,
because it is portable between engines.
ALTERNATIVES CONSIDERED
A. Lake only (Parquet and DuckDB). Rejected: it fails RQ-05 and RQ-10.
B. Lake + classic warehouse. Rejected: double copy and double governance
(RQ-13), and consumption in a proprietary format (ADR-003).
C. Delta Lake. Rejected as the first option: its best support is tied to
specific ecosystems; Iceberg is the most neutral.
D. Apache Hudi. Rejected: geared toward updates in a continuous stream,
which ADR-010 does not provide for.
CONDITIONS FOR RECONSIDERING
- If the proof of concept or operations do not meet RQ-05 after
optimizing: reserved compute or the engine's native storage for the
most queried tables (a step toward alternative B, only for those
tables).
- If the chosen provider supports Delta Lake better than Iceberg: the
format is changed. Both store Parquet; the dbt logic does not change.
- Sustained volume above 50 GB/day (ADR-011).
CONSEQUENCES
Positive: one copy, one governance, no servers to administer; cost
proportional to use; portable data and logic.
Negative: table maintenance has to be operated; somewhat higher latency
than a native warehouse; dependence on the provider's catalog.
Follow-up work: proof of concept; adapt the micro-batch scripts and the
DuckDB reads to Iceberg; maintenance DAG.The type of engine, without marrying a vendor
The ADR describes a type of service, consistent with the neutrality of ADR-003. Examples of the same type:
| Cloud | Equivalent service | Remark |
|---|---|---|
| AWS | Amazon Athena (or Redshift Serverless) with the provider's data catalog | Native Iceberg; payment by data read |
| Google Cloud | BigQuery with Iceberg tables | Serverless; payment by data read or by capacity |
| Azure | Microsoft Fabric or Azure Synapse serverless | Ecosystem centered on Delta Lake: the ADR's second condition would apply |
| Multicloud | Snowflake or Databricks SQL | Compute that suspends itself; payment by usage time |
Why Iceberg? Because DataCorp has not chosen a provider and it is the format that the most engines read and write; because its hidden partitioning simplifies the analysts' queries; and because DuckDB and Python handle it, which preserves ADR-011. And why will it be enough for RQ-05? Because the dashboards read certified aggregate tables of a few thousand rows (ADR-014), not the detailed facts, and Metabase adds its own cache.
DataCorp's target architecture
With ADR-015, all the decisions of the course fit into a single figure: the target architecture (the to-be state), which replaces the as-is diagram of lesson 01-03.
flowchart LR
subgraph FU["Sources"]
PG["Orders PostgreSQL<br/>(read replica)"]
ERP["Warehouse ERP<br/>(CSV and API)"]
MK["Marketing<br/>(CSV and API)"]
SP["Support<br/>(ticket API)"]
WEB["Web and app<br/>(JSON events)"]
end
subgraph ING["Ingestion"]
PY["Python scripts<br/>datacorp-data/ingestion"]
MSG["Managed messaging<br/>topic clickstream.events"]
end
subgraph LH["DataCorp lakehouse (object storage, one EU region)"]
BR[("Raw<br/>original format + gzip<br/>datacorp-data-raw")]
DE[("Cleansed<br/>Iceberg tables<br/>datacorp-data-cleansed")]
CO[("Consumption<br/>Iceberg tables: facts,<br/>dimensions, aggregates<br/>datacorp-data-consumption")]
CAT["Technical catalog<br/>tables and permissions by role"]
end
subgraph PR["Processing"]
SQLM["Serverless SQL engine<br/>compute: load / query"]
DBT["dbt Core<br/>models + DQ tests"]
DK["Python + DuckDB<br/>micro-batches"]
end
subgraph CS["Consumption"]
MB["Metabase<br/>5 official dashboards"]
AN["SQL and notebooks<br/>datacorp-analysis"]
AL["Stock alerts"]
end
PG --> PY
ERP --> PY
MK --> PY
SP --> PY
WEB --> MSG
PY --> BR
MSG --> BR
BR --> DK --> DE
BR --> DBT
DBT --> SQLM
SQLM --> DE
DE --> SQLM
SQLM --> CO
CO --> MB
CO --> AN
CO --> AL
CAT -.-> DE
CAT -.-> CO
ORQ["Managed Airflow: 6 load DAGs + table_maintenance"] -.-> ING
ORQ -.-> PR
GOB["Governance as code: datasheets, glossary, contracts, metrics · Roles with SSO and MFA · #data-alerts"] -.-> LH
From here on, "the analytical platform" is DataCorp's lakehouse and "the analytical engine" is a managed, serverless SQL engine over Iceberg tables.
Common Mistakes and Tips
- Believing that the table format is an engine. It is a specification of files and metadata; you need an engine that reads it and a catalog that arbitrates.
- Forgetting maintenance. A table that receives 96 micro-batches a day accumulates thousands of small files and snapshots within a few weeks.
- Reading the folder instead of the table. A
read_parquetover the folder of an Iceberg table also returns the files of old snapshots: deleted and duplicated rows. Always read through the format. - Considering deleted what is only logically deleted. Until the snapshots expire, the data exists. And time travel is not a backup either: it lives in the same storage as the data.
- Tip: before committing, test the three critical operations with your data: a MERGE, a read concurrent with a write and a compaction.
- Tip: keep the logic in standard SQL. It is the insurance against any change of engine or format.
Exercises
Exercise 1: Following the snapshots
An Iceberg table goes through these operations: (1) initial load, which writes files A and B; (2) insert, which adds C; (3) update of rows contained in A, which writes A'; (4) compaction of B and C into a file BC. State which files make up each snapshot and which ones physically exist in storage after step 4 if no snapshot has expired.
Exercise 2: MERGE of facts
Write the MERGE that loads consumption.fact_sales from an intermediate table intermediate.int_sales_lines with the same columns, using line_id as the key and updating only order_status when it has changed. Why is the condition in the WHEN MATCHED important?
Exercise 3: Erasure deadline
A customer requests erasure on March 2. The procedure runs the DELETE in that night's load. With the snapshot retention of ADR-015 and that of the raw zone for postgres/customers (lesson 03-04), on what date, at the latest, does their data physically cease to exist on the platform? What assumption has to be checked?
Solutions
Exercise 1
| Snapshot | Files that make it up |
|---|---|
| 1 | A, B |
| 2 | A, B, C |
| 3 | A', B, C |
| 4 | A', BC |
After step 4, A, B, C, A' and BC physically exist: five files, of which the current table uses only two. The others enable time travel and will be removed when snapshots 1 to 3 expire. Key point: updating and compacting do not delete anything at the time; the space is reclaimed by maintenance.
Exercise 2
MERGE INTO consumption.fact_sales AS f
USING intermediate.int_sales_lines AS n
ON f.line_id = n.line_id
WHEN MATCHED AND f.order_status <> n.order_status THEN
UPDATE SET order_status = n.order_status
WHEN NOT MATCHED THEN
INSERT (line_id, order_id, date_sk, customer_sk, product_sk, campaign_sk,
order_status, quantity, gross_amount, net_amount)
VALUES (n.line_id, n.order_id, n.date_sk, n.customer_sk, n.product_sk,
n.campaign_sk, n.order_status, n.quantity, n.gross_amount, n.net_amount);Without the condition AND f.order_status <> n.order_status, every load would "update" all the matching rows, even if they had not changed. Since DataCorp re-extracts the last 60 days, two months of files would be rewritten every night: more compute, more files to compact and more bulky snapshots. In practice, dbt generates this statement from an incremental model (lesson 04-02).
Exercise 3
The DELETE is committed on the night of March 2 to 3. The earlier snapshots expire after 7 days: at the latest, the maintenance run of March 10 removes the files from the cleansed and consumption zones. In the raw zone, the last full customer extraction that included them is the one from the early hours of March 2 (before the request), and it is kept for 14 days: until March 16. That is the latest date, comfortably within the one-month deadline.
The assumption that has to be checked: that the customer has also been erased or anonymized at the source (the orders PostgreSQL). Otherwise, the following night's full extraction would bring them back. And, as with any question of legal deadlines, the calculation must be validated by the data protection officer.
Conclusion
A data lakehouse offers the management and performance of a warehouse on the cheap, open storage of the lake, with a single copy of the data. It is made possible by open table formats (Delta Lake, Apache Iceberg and Apache Hudi), which add a transaction log and snapshots to the Parquet files, and with them ACID transactions, MERGE and deletes, schema and partition evolution, time travel and compaction; a technical catalog arbitrates the writes and lets several engines work on the same tables. In exchange, maintenance has to be operated and a somewhat higher latency than that of a native warehouse accepted. With ADR-015, DataCorp adopts a simple lakehouse: a raw zone in the original format, cleansed and consumption zones in Iceberg tables and a managed, serverless SQL engine that runs dbt and serves Metabase. The architecture now has a name, a shape and a target diagram.
One dimension remains that the diagram does not show: time. The lakehouse says where the data lives, but not how to combine an exact history with newly arrived data when responses within seconds are required. Two much-cited processing architectures were proposed for that problem, Lambda and Kappa. The next lesson explains them and checks whether DataCorp's design, with its batches and micro-batches, is either of the two.
