What each layer is for
The medallion pattern (the name was popularized by Databricks, the idea is older) splits a lakehouse into layers that each answer a different question. bronze answers "what exactly did the source send us, and when?" silver answers "what is true about the business entities?" gold answers "how do people want to ask questions about it?" The semantic model on top answers "what do the numbers mean?"
Framed that way, the layers are less about data quality tiers and more about ownership. Each one has work it owns and work it must refuse.
| Layer | Owns | Must not | Sample tables |
|---|---|---|---|
| bronze | A faithful, replayable copy of the source. Load metadata (_ingested_at, _batch_id). Source column names as-is. | Rename into business terms, filter rows, join, or deduplicate anything beyond exact technical duplicates. | bronze.erp_sales_order_header, bronze.erp_customer, bronze.crm_salesperson, bronze.files_budget |
| silver | Typing, cleansing, deduplication, conforming codes, one row per entity (or entity version), row-level derivations. | Aggregate, apply report-specific filters, or shape tables for one consumer. | silver.sales_order_line (header joined to lines, net_amount derived), silver.customer, silver.budget |
| gold | Dimensional shape: grain, surrogate keys, SCD history, conformed dimensions, facts. | Cleanse source data (that leaked from silver) or hold ratios and report-only calculations. | dim_customer, dim_date, fact_sales, fact_inventory_daily, fact_budget |
| semantic | Relationships, measures, friendly names, security, formatting. | Row-level transformation (Power Query fixes, calculated columns that patch upstream data). | "Sales & Inventory" |
The contract between layers
Every boundary is a contract with five clauses: schema, grain, keys, freshness and quality. Write them down, and better, write them as tests that run after each load.
- Bronze to silver. Bronze promises completeness and replay: every batch the source delivered is there, tagged with a
_batch_id, and can be reprocessed. It promises nothing about cleanliness. - Silver to gold. Silver promises one row per business key (or per key and version), typed columns, conformed code values and stable business keys. For
silver.sales_order_linethat means one row per(order_number, line_number),net_amount = gross_amount - discount_amount, a non-nullorder_date, and acustomer_idthat resolves insilver.customeror is explicitly flagged. - Gold to semantic. Gold promises a declared grain per fact, a surrogate key on every dimension (with an unknown member), and no orphaned fact keys. The model can then rely on one-to-many relationships without defensive DAX.
If a consumer two layers up has to know a quirk of the source system to get the right answer, a contract was broken somewhere in between. Fix it at the lowest layer that could have absorbed it.
A minimal set of contract tests for one silver table looks like this, and it is worth running on every load rather than in a quarterly audit:
-- silver.sales_order_line: grain and key tests (expect zero rows each)
SELECT order_number, line_number, COUNT(*) AS n
FROM silver.sales_order_line
GROUP BY order_number, line_number
HAVING COUNT(*) > 1;
SELECT s.order_number, s.line_number
FROM silver.sales_order_line AS s
LEFT JOIN silver.customer AS c ON c.customer_id = s.customer_id
WHERE c.customer_id IS NULL;
SELECT order_number, line_number
FROM silver.sales_order_line
WHERE net_amount <> gross_amount - discount_amount;
Where business logic belongs
"Business logic" is too broad a phrase to place in one layer. Split it into four kinds and the placement becomes clear:
- Cleansing logic (trim, cast, map
'Y'/'N'to booleans, fix known bad codes) belongs in silver. It is about the source, so it should be done once, near the source. - Entity logic (joining order header to lines, deriving
net_amount, picking the surviving record when two systems describe the same customer) also belongs in silver. It defines what an entity is. - Analytical shaping (surrogate keys, SCD history, role-playing date keys, the unknown member) belongs in gold. It is about how the entity will be queried.
- Aggregation logic (ratios, time comparisons, anything that depends on what the user filtered) belongs in semantic measures. Margin % is a ratio of sums; storing it on a row is wrong the moment someone sums it.
The awkward middle is a derived attribute like customer segment. If more than one consumer needs it (a report and a data science notebook), compute it in silver or as a gold dimension attribute. If only the model needs it and it depends on report-time selections, it is a measure.
Logic hidden in a semantic model's Power Query steps is invisible to every other consumer of the lakehouse. It is also unavailable once the model moves to Direct Lake, which has no Power Query layer for its tables. Treat Power Query fixes in a model as debt that belongs in silver.
Bronze: copies, shortcuts or views
Bronze does not have to be a physical copy. There are three common shapes, and the choice is really about where replay lives.
| Copy (Copy activity, Copy job) | Shortcut or mirror | View over a shortcut or mirror | |
|---|---|---|---|
| History and replay | Yes, every batch is kept | Only what the source keeps | Only what the source keeps |
| Latency | Schedule-bound | Current (mirroring is near real time) | Current |
| Storage | Second copy in OneLake | None (shortcut) or managed replica (mirror) | None |
| Source schema change | Absorbed at landing | Felt immediately downstream | Felt at the view, can be adapted there |
| Good for | Volatile sources, APIs, files, anything you may need to replay | Data already in Delta, other lakehouses, ADLS, S3 | Light renaming or column selection without a copy |
When bronze is a shortcut or view, the replay promise moves to the source. That is fine when the source is an append-only landing zone or a mirror with history, and risky when it is an operational database that overwrites rows. In the sample model, the ERP tables could reasonably be mirrored, while crm.salesperson (API JSON) and files.budget (CSV) should be copied, because nobody keeps their history for you.
OneLake shortcuts to Delta data appear under a lakehouse's Tables and are queryable through the SQL analytics endpoint, which is read-only. Views created in the SQL analytics endpoint are T-SQL views; they are not the same object as Spark catalog views, so a notebook will not see them. Bronze views are a fine input to a silver notebook or T-SQL load, but a poor direct source for a semantic model: Direct Lake on the SQL endpoint falls back to DirectQuery for views, and Direct Lake on OneLake cannot read them at all.
Silver refresh before the warehouse load
The order of operations matters more than any single transform. A reliable run looks like this:
- Land bronze (or confirm the shortcut or mirror is current) and record a
_batch_id. - Refresh silver completely and run its contract tests. Stop the run if they fail.
- Load gold dimensions (
dim_customer,dim_product,dim_warehouse,dim_salesperson;dim_daterarely changes). - Load gold facts, looking up surrogate keys against the dimensions just loaded.
- Refresh or reframe the semantic model.
Silver must finish first because gold change detection compares against it. A dimension load that reads a half-refreshed silver.customer will see missing customers as deletions or produce false Type 2 versions. Dimensions go before facts so that every fact row finds its key, and anything that does not is routed to the unknown member or an inferred member, never silently dropped.
A common split is silver in a Lakehouse (Spark notebooks) and gold in a Warehouse (T-SQL). The Warehouse can read lakehouse tables in the same workspace with three-part names, for example SilverLakehouse.silver.sales_order_line in a schema-enabled lakehouse. Warehouse multi-table transactions let a dimension and fact load commit together. Put the semantic model refresh as the last pipeline activity, and consider turning off the model's automatic Direct Lake updates so framing happens only after a complete, tested load.
When to add a layer, or skip one
Three layers is a default, not a law.
- Skip silver when the source is already clean and entity-shaped (a well-run SaaS API, a curated upstream lakehouse) and gold has one consumer. The cost is that gold transforms absorb the cleansing. That is tolerable for one consumer and painful by the third.
- Add a serving or "platinum" layer when several models or tools need the same aggregated or cross-domain tables: an aggregate fact for a very large model, a wide feature table for data science, or a domain-specific mart built from shared gold. Many teams simply count the semantic model as the fourth layer, which is fair.
- Do not add layers for appearance. Each layer is another copy to keep fresh, test and explain. A layer earns its place by owning a responsibility nobody else can.
If bronze is a set of views over mirrored sources and silver is mostly renames and casts, is silver still worth materializing? The deciding factor is usually how many consumers read the cleaned entities. See Open questions.
Lakehouse or Warehouse for gold
| Factor | Lakehouse gold | Warehouse gold |
|---|---|---|
| Write engine | Spark (PySpark, Spark SQL) | T-SQL |
| Transactions | ACID per Delta table | Multi-table transactions |
| SQL access | SQL analytics endpoint, read-only | Full read and write T-SQL |
| Direct Lake | Yes | Yes |
| Security in SQL | Endpoint-level object and row security; OneLake security is still evolving | GRANT, row-level security, column-level security, dynamic data masking |
| Best fit | Python-heavy transforms, data engineering teams | SQL-first teams, dimension and fact loads that must commit together |
Pick the engine your team is fluent in and keep a subject area's gold in one place. Splitting fact_sales into a lakehouse and its dimensions into a warehouse doubles the ways a load can half-succeed.
The Medallion stack lets you drill from layer to table to column on the sample model, and the Lineage flow shows every table from source to report.