Skip to the page
Tecyfy

Medallion Architecture in Databricks: Bronze, Silver and Gold Done Right

What each medallion layer is for, how to build bronze, silver and gold as one Databricks pipeline with streaming tables, AUTO CDC and materialized views, where the layers go in Unity Catalog, and how often to refresh them.

Tecyfy · Published · Updated · 8 min read

The Medallion ArchitectureMedallion ArchitectureOrganising a lakehouse in 3 layers of rising quality: bronze for raw data, silver for cleaned and joined data, and gold for tables shaped for reports and AI. organises a LakehouseLakehouseOne store for all of an organisation's data: cheap files in cloud storage, as in a data lake, with the tables, transactions and fast queries of a data warehouse on top. in three layers of rising quality. Bronze keeps the raw data exactly as it arrived, silver holds that data cleaned, deduplicated and joined, and gold holds tables shaped for reports, dashboards and AI. Each layer is built only from the one before it, so a mistake can always be fixed by replaying from bronze. Databricks calls it a recommended practice, not a requirement.

This guide covers what belongs in each layer, a complete bronze-to-gold Data PipelineData PipelineA set of steps that moves data from where it is made to where it is used, cleaning and reshaping it on the way, run on a schedule or as data arrives. written in SQL, where the layers go in Unity Catalog, and how often to refresh them.

What each layer is for

LayerHoldsRead byRule of thumb
BronzeRaw records as they arrived, plus where they came fromData engineers, auditChange as little as possible
SilverOne clean, validated, deduplicated row per recordEngineers, analysts, data scientistsBuilt from bronze, never straight from the source
GoldBusiness-shaped tables and aggregatesAnalysts, dashboards, ML, appsModelled for the questions people ask

The layers are about trust, not storage. A dashboard should never read bronze, and a fix should never be patched into gold by hand.

Bronze: keep it raw

Bronze is your record of what the source sent. Three practices from Databricks' own guidance:

  • Clean almost nothing. Bronze is append-only. A bad record stays, so you can find and replay it later.
  • Store loosely typed columns. Keep most fields as STRING, VARIANT or binary. A source that changes a type tomorrow then cannot break ingestion. (For semi-structured data, see our VARIANT benchmark.)
  • Record where each row came from. At minimum the source file and the load time.

On Databricks, bronze is usually a streaming table fed by Auto Loader. Auto Loader picks up only the files it has not seen, infers the schema and adds new columns as they appear. Values that do not match the schema go into a rescued-data column instead of being lost, which is how bronze survives Schema DriftSchema DriftWhen the shape of incoming data changes without warning, such as a renamed or new column, and breaks or silently corrupts the pipelines that read it..

CREATE OR REFRESH STREAMING TABLE ops.bronze.orders_raw
AS SELECT
  *,
  _metadata.file_path AS source_file,
  current_timestamp() AS ingested_at
FROM STREAM read_files(
  '/Volumes/ops/landing/orders/',
  format => 'json'
);

_metadata is not part of SELECT *, so name it explicitly.

Silver: one trustworthy row per record

Silver is where the data becomes something you would let an analyst query. Typical work here: enforce the schema, cast types, handle nulls, drop duplicates, cope with late or out-of-order records, and join reference data.

Two rules matter most:

  1. Build silver from bronze, not from the source. If ingestion writes straight into silver, one corrupt file or one schema change fails the table everyone depends on.
  2. Keep at least one non-aggregated copy of every record. Gold aggregates are rebuilt from silver; if silver is already summarised, the detail is gone.

Put the Data QualityData QualityHow far data can be trusted: complete, correct, on time and in the expected shape. Pipelines check it with rules and stop or flag rows that fail. rules in the table definition as expectations, so every update is checked and counted:

CREATE OR REFRESH STREAMING TABLE ops.silver.orders_clean (
  CONSTRAINT has_id     EXPECT (order_id IS NOT NULL) ON VIOLATION DROP ROW,
  CONSTRAINT valid_qty  EXPECT (quantity > 0)         ON VIOLATION DROP ROW,
  CONSTRAINT known_type EXPECT (status IN ('NEW', 'PAID', 'SHIPPED', 'CANCELLED', 'DELETED'))
)
AS SELECT
  CAST(order_id AS BIGINT)            AS order_id,
  CAST(customer_id AS BIGINT)         AS customer_id,
  CAST(quantity AS INT)               AS quantity,
  CAST(amount AS DECIMAL(12, 2))      AS amount,
  upper(status)                       AS status,
  CAST(updated_at AS TIMESTAMP)       AS updated_at,
  source_file
FROM STREAM(ops.bronze.orders_raw);

An expectation with no ON VIOLATION keeps the row and counts it; DROP ROW removes it before it lands; FAIL UPDATE stops the update. Use FAIL UPDATE only for rules whose breach means the whole load is wrong.

Keeping the latest version of each record

Sources such as databases send every change to a row, not just the latest state. Instead of writing a MERGE by hand, let the pipeline apply the changes in order with AUTO CDC (it takes the place of APPLY CHANGES, which still works, and has the same syntax). This is Change Data CaptureChange Data CaptureCopying only the rows that were added, changed or deleted in a source database, read from its change log, instead of copying the whole table again. done for you: it orders the changes, applies deletes and keeps one current row per key.

CREATE OR REFRESH STREAMING TABLE ops.silver.orders_current;

CREATE FLOW orders_cdc AS AUTO CDC INTO ops.silver.orders_current
FROM STREAM(ops.silver.orders_clean)
KEYS (order_id)
APPLY AS DELETE WHEN status = 'DELETED'
SEQUENCE BY updated_at
COLUMNS * EXCEPT (source_file)
STORED AS SCD TYPE 1;

Use STORED AS SCD TYPE 2 instead when you need every past version with its valid-from and valid-to times.

Read bronze as a stream whenever the source only appends. Plain batch reads suit small tables, such as a short list of countries or product types.

Gold: shaped for the question

Gold tables answer business questions directly. Databricks' advice:

  • Model for reporting, usually as facts and dimensions with clear measures, so every dashboard counts revenue the same way.
  • Pre-aggregate what people ask for again and again as materialized views. The pipeline keeps them up to date, so no analyst rebuilds the same sum.
  • Split gold by domain when teams need different shapes: one for finance, one for sales.
  • Keep long history in silver. Gold should be small and fast; it is queried far more often than it is written.
CREATE OR REFRESH MATERIALIZED VIEW ops.gold.daily_revenue
AS SELECT
  date(updated_at)       AS order_date,
  count(*)               AS orders,
  sum(amount)            AS revenue
FROM ops.silver.orders_current
WHERE status IN ('PAID', 'SHIPPED')
GROUP BY date(updated_at);

These three files make one pipeline. The pipeline works out the order from the table names, and the streaming tables read only the records they have not seen. For how such pipelines are declared and run, see our Spark Declarative Pipelines guide.

Where the layers live in Unity Catalog

The older advice was one catalog per layer (bronze_catalog, silver_catalog, gold_catalog). Databricks' current guidance points elsewhere:

  • Catalogs usually follow environments, teams or business units: for example dev, test and prod, or sales and finance.
  • Layers are schemas inside a catalog: prod.bronze, prod.silver, prod.gold. Databricks' own medallion example does exactly this.
  • Grant by schema. Engineers can write all three; analysts get SELECT on gold (and perhaps silver) only.
  • Use managed tables for every new table, so Unity Catalog's governance and automatic optimizations apply.

A separate catalog per layer still makes sense when a layer has different isolation needs, for example raw data containing personal details that only one workspace may see. Catalogs can be bound to specific workspaces for that.

Keep the tables fast

Lay out silver and gold tables with liquid clustering, not partitions and ZORDER. On Unity Catalog managed tables with predictive optimization, CLUSTER BY AUTO lets Databricks choose keys from the table's query history and change them when the expected savings outweigh the cost of reclustering. Our liquid clustering guide covers keys, conversion and limits.

CREATE OR REFRESH STREAMING TABLE ops.silver.orders_current CLUSTER BY AUTO;

How often to refresh

Each layer can run at a different pace. The choice is cost against freshness:

ModeHowCostDelay
ContinuousPipeline in continuous modeHighest: compute always onSeconds
TriggeredPipeline on a schedule or when files arriveLowerMinutes to hours
BatchPlain reads and partition overwritesLowest per runHours; needs date-partitioned sources

Most teams run triggered pipelines: incremental like streaming, but paying for compute only while the update runs.

Common mistakes

  • Cleaning in bronze. Filtering bad rows at ingestion throws away the evidence you need to debug the source.
  • Analysts on bronze. Raw tables change shape and contain duplicates; numbers built on them will disagree.
  • Full rewrites every run. mode("overwrite") on every layer re-reads everything. Streaming tables and materialized views process only what is new.
  • One gold table for everyone. Domains end up fighting over column meanings. Give each its own.
  • Medallion for its own sake. Three copies of a small, already-clean table add cost and nothing else. Use the layers where the data actually needs them.

Tecyfy Takeaway

  • Bronze keeps the source's records untouched, loosely typed and labelled with where they came from.
  • Silver turns them into one validated row per record, with quality rules in the table and AUTO CDC for changes.
  • Gold shapes them for the questions people ask, with materialized views for common aggregates.
  • Put the layers in schemas within environment catalogs, use managed tables, cluster with CLUSTER BY AUTO, and choose triggered refreshes unless you truly need seconds.

Questions

What is the medallion architecture?
A way of organising a lakehouse in 3 layers of rising quality: bronze keeps raw data as it arrived, silver holds it cleaned, deduplicated and joined, and gold holds tables shaped for reports, dashboards and AI. Each layer is built only from the one before.
What should go in the bronze layer?
The source's records almost untouched and append-only, with most fields loosely typed as STRING or VARIANT, plus where each row came from and when it was loaded. On Databricks it is usually a streaming table fed by Auto Loader.
Should bronze, silver and gold be separate catalogs in Unity Catalog?
Databricks' current guidance is no: catalogs follow environments or business units, such as dev and prod, and the layers are schemas inside them, such as prod.bronze and prod.gold. A separate catalog still makes sense when a layer needs its own isolation.
How do I keep the latest version of each record in silver?
Use AUTO CDC, the recommended replacement for APPLY CHANGES, which still works and has the same syntax. It orders the changes by a sequence column, applies deletes and keeps one current row per key with SCD type 1, or every past version with SCD type 2.
How often should medallion layers refresh?
Most teams run triggered pipelines, on a schedule or when files arrive: incremental like streaming, but paying for compute only while the update runs. Continuous mode gives delays of seconds at the highest cost.