Sub topic 1
What the Medallion Architecture Is and Why It Exists
The medallion architecture organizes data in a lakehouse into three layers of increasing quality: bronze, silver, and gold. Each layer is a set of Delta tables. Data moves forward through the layers, and each step adds structure, cleaning, or business meaning. This chapter explains the idea and the problems it solves. The rest of the tutorial builds each layer.
Prerequisites
This chapter assumes you already know the following:
- Basic SQL: SELECT, JOIN, and GROUP BY.
- Basic PySpark DataFrame usage.
- What a data lake is, and how file formats such as JSON and Parquet differ.
- Where to find notebooks and compute in a Databricks workspace.
You do not need to know Delta Lake internals, Auto Loader, or Unity Catalog yet. Later chapters introduce each of them when it is needed.
The problem the pattern solves
Consider a team that receives order data as JSON files from a web shop. Analysts want a daily revenue number. The simplest approach is to point a dashboard query at the raw files. That approach tends to fail in predictable ways:
- Raw data is messy. Amounts arrive as strings, timestamps use mixed formats, and some records have no key.
- Source systems change. A new field appears, or an old one is renamed. Every downstream query breaks at once.
- Fixes are lossy. If you clean the data in place and later find a bug in the cleaning logic, the original values are gone. You cannot rerun the fix.
- Everyone repeats the work. Each analyst writes their own cleaning logic, so two dashboards report different revenue for the same day.
- Access is all or nothing. Granting access to the raw data exposes everything in it, including fields most people should not see.
The medallion architecture addresses these problems by separating concerns. One layer keeps the original data. One layer holds a cleaned, shared version. One layer holds tables shaped for specific questions. Each layer has one job, and a defect found in a later layer can be fixed by recomputing from an earlier one.
The three layers
| Layer | Holds | Typical shape | Main consumers |
|---|---|---|---|
| Bronze | Data as received from the source, plus load metadata | Append-only, close to source structure, often loosely typed | Data engineers, reprocessing jobs |
| Silver | Cleaned, typed, deduplicated, conformed data | One table per business entity, such as orders or customers | Data engineers, data scientists, analysts who need detail |
| Gold | Aggregates and marts built for a purpose | Denormalized, business-named tables | Dashboards, reports, ML features, business users |
Bronze: the raw record
Bronze stores what arrived, with little or no change. It adds metadata about the load, such as the ingestion time and the source file name. The goal is a replayable history. If silver logic turns out to be wrong, you reread bronze and rebuild silver. Bronze is normally append-only, so history is never rewritten.
Bronze is not a place for business rules. Dropping bad rows there defeats its purpose, because you lose the evidence of what the source sent.
Silver: the shared, trusted version
Silver applies the transformations every consumer would otherwise repeat. It casts columns to proper types, removes duplicates, filters out records that cannot be used, standardizes names and codes, and sometimes joins reference data. Silver tables usually stay at the same grain as the source. An orders table in silver still has one row per order. The result is a single place where "an order" has one definition.
Gold: shaped for the consumer
Gold tables answer specific business questions. A daily revenue table, a customer lifetime value table, or a feature table for a model are typical examples. They aggregate, join, and rename for readability so that a dashboard can query them without further logic. Gold tables are usually small relative to silver and are queried often.
How the layers connect
Two properties of this flow matter in practice.
- Data moves one way. Silver reads from bronze, and gold reads from silver. Gold does not write back into silver. One-way flow keeps lineage easy to follow, because every table can be traced to its sources.
- Each hop is a recompute boundary. Because bronze keeps the raw data, you can rebuild silver and gold from it at any time. This is the main reason the pattern is resilient to mistakes.
A small worked example
The following SQL runs in a Databricks notebook without any setup. It creates a few raw rows as temporary views and moves them through the three layers. In a real pipeline these would be Delta tables, which later chapters cover.
-- Bronze: values exactly as received, all strings, one row has no key
CREATE OR REPLACE TEMP VIEW bronze_orders AS
SELECT * FROM VALUES
('1001', 'c-7', '2026-12-01T10:15:00', '19.90', 'completed'),
('1002', 'c-8', '2026-12-01T11:40:00', '45.00', 'completed'),
('1003', 'c-7', '2026-12-01T12:05:00', '12.50', 'cancelled'),
(NULL, 'c-9', '2026-12-01T13:00:00', '8.00', 'completed'),
('1005', 'c-2', '2026-12-02T09:30:00', '30.00', 'completed')
AS t(order_id, customer_id, order_ts, amount, status);
-- Silver: typed columns, rows without a key removed
CREATE OR REPLACE TEMP VIEW silver_orders AS
SELECT
order_id,
customer_id,
CAST(order_ts AS TIMESTAMP) AS order_ts,
CAST(amount AS DECIMAL(12,2)) AS amount,
status
FROM bronze_orders
WHERE order_id IS NOT NULL;
-- Gold: one row per day, completed orders only
CREATE OR REPLACE TEMP VIEW gold_daily_revenue AS
SELECT
CAST(order_ts AS DATE) AS order_date,
COUNT(*) AS orders,
SUM(amount) AS revenue
FROM silver_orders
WHERE status = 'completed'
GROUP BY CAST(order_ts AS DATE);
SELECT * FROM gold_daily_revenue ORDER BY order_date;The final query returns two rows: 2026-12-01 with 2 orders and 64.90 in revenue, and 2026-12-02 with 1 order and 30.00. The bronze view still contains all five rows, including the one without a key and the cancelled order. If someone later asks why an order is missing from the revenue figure, you can inspect bronze and answer.
Why this works on Databricks
The pattern is a design convention, not a product feature. Databricks does not enforce the layers. Several platform features make the convention practical:
- Delta Lake tables give each layer ACID transactions, schema enforcement, and a table history. Chapter 2 covers this foundation.
- Unity Catalog gives each layer a named place and its own permissions. A later chapter maps layers to catalogs and schemas.
- Structured Streaming and Auto Loader let each layer process only new data instead of rereading everything.
- Declarative pipelines let you define all three layers as one unit with data quality rules attached.
Edge cases and common misunderstandings
- The names are not fixed. Some teams call the layers raw, refined, and curated, or use a numeric scheme. The labels matter less than the contract each layer keeps.
- Three is a guideline. Some pipelines add a staging layer before bronze or a second silver step. Others skip gold because silver already serves the consumers. The final chapter weighs these choices.
- Silver is not a data warehouse model. Silver is cleaned, but it does not have to be a star schema. Dimensional modeling usually happens in gold.
- Layers are not quality grades you can skip to. A consumer who reads bronze directly gets raw, possibly duplicated data. Permissions should steer most consumers to gold.
- Duplication of storage is intentional. The same fact exists in three forms. You pay for extra storage in exchange for replayability and clear responsibilities.
What the rest of the tutorial builds
The following chapters take one concept at a time: Delta tables, the Unity Catalog layout, ingestion into bronze, incremental processing, the silver transformations, MERGE, data quality rules, gold tables, declarative pipelines, jobs, permissions, table maintenance, and the trade-offs of the pattern. By the end you will have built the same three-layer flow shown above as a production-style pipeline.
Exercise
A source system sends orders where some amounts are the text "N/A". A teammate proposes dropping those rows during ingestion so bronze stays "clean". Which layer should handle these rows, and why?
Show answer
Silver should handle them. Bronze should store the rows exactly as received, so you keep evidence of what the source sent and can replay if the rule changes. Silver is where you cast amount to a decimal type and decide whether to drop, quarantine, or flag rows that fail the cast.
Exercise
You find a bug in your silver deduplication logic that has been running for a month. What property of the medallion architecture lets you correct the silver and gold tables, and what must be true of bronze for it to work?
Show answer
Each layer can be recomputed from the one before it. This works only if bronze is an append-only, unmodified record of the source data for the whole period. You fix the silver logic, rebuild silver from bronze, then rebuild gold from the new silver.