Sub topic 4
Bronze: land raw data and keep it replayable
This chapter covers the bronze layer: what it stores, the rules that keep it useful, and how you rebuild downstream tables from it. It assumes you know the medallion layers at a high level, can read basic Delta Lake SQL, and have a catalog and schema layout like the one in the previous chapter. The next chapter covers the Auto Loader mechanics. Here the focus is on the design of the bronze table itself.
What bronze is for
Bronze is the first Delta table layer. Data lands here as close to its source form as possible. Bronze has two jobs:
- It is a durable, queryable copy of what the source sent, in Delta format.
- It is the point you replay from when downstream logic changes or breaks.
The second job drives most design choices. Suppose you find a bug in a silver transformation three weeks after it shipped. If bronze still holds the original records, you fix the code and rebuild silver. If bronze was cleaned on the way in, the original values are gone and you may not be able to recover them from the source.
Design rules for a bronze table
Most good bronze tables follow the same small set of rules.
- Append only. New data is inserted. Existing rows are not updated or merged. Duplicates in the source stay duplicates in bronze, and silver handles them.
- Keep the source's shape. Keep column names, nesting, and values as the source sent them. Do not rename, join, filter, or aggregate.
- Add load metadata. Record when and where each row came from, so you can trace and replay it.
- Be permissive about schema. A change in the source must not stop ingestion or silently drop data.
- Keep rows you do not understand. Malformed or unexpected data goes into the table with a marker. It is not discarded.
The reasoning is simple. Bronze should rarely fail, because a failure there means data is not arriving. Cleaning logic is where failures happen, so it belongs in silver, where a failure delays a rebuild but loses nothing.
Anatomy of a bronze table
You can let ingestion create the table, but defining it explicitly makes the contract visible. This example declares source columns as strings, adds metadata columns, and turns on Delta's append-only protection.
CREATE TABLE IF NOT EXISTS main.bronze.orders (
order_id STRING,
customer_id STRING,
order_ts STRING,
amount STRING,
status STRING,
_rescued_data STRING,
_ingested_at TIMESTAMP,
_source_file STRING
)
COMMENT 'Raw orders as delivered by the sales system. Append only.'
TBLPROPERTIES (delta.appendOnly = true);Three details are worth noting:
- String types.
order_tsandamountare strings on purpose. If the source sends"N/A"in an amount field, a string column accepts it and silver decides what to do. A decimal column would reject the row or fail the load. _rescued_data. Auto Loader fills this column with a JSON string holding any data that did not fit the schema, such as an unexpected column or a value of the wrong type. Keeping the column means nothing is dropped.delta.appendOnly = true. This property makes Delta rejectUPDATE,DELETE, andMERGEon the table. It enforces the append-only rule instead of relying on discipline.
Metadata columns
Metadata columns describe the load, not the business event. A common convention is a leading underscore, which separates them from source fields.
| Column | Source | Why it helps |
|---|---|---|
| `_ingested_at` | `current_timestamp()` at load | Orders duplicate versions of a record and bounds replay windows |
| `_source_file` | `_metadata.file_path` | Traces a bad row to the exact file that delivered it |
| `_rescued_data` | Auto Loader | Holds data that did not match the schema |
| `_file_modification_time` (optional) | `_metadata.file_modification_time` | Shows when the source produced the file, which can differ from load time |
_ingested_at is the most important one. The silver deduplication step in this tutorial uses it to pick the latest version of each order_id. Without it, "latest" has no meaning.
If a source is hard to flatten or changes shape often, some teams also store the whole record as a single string column, for example _raw. Silver then parses it with from_json. This costs storage and makes bronze harder to query directly. It is the most tolerant option, so consider it for unstable or deeply nested feeds.
Staying permissive about schema
Sources change. A new field appears, a number arrives as text, a field is renamed. Bronze should absorb these changes. There are three common approaches:
- Everything as strings. For JSON and CSV, Auto Loader infers columns as strings unless you set
cloudFiles.inferColumnTypestotrue. This is a good default for bronze. - Rescue unexpected data. The
_rescued_datacolumn catches fields that were not in the schema. You can check it later and promote real new fields into silver deliberately. - Pick a schema evolution mode on purpose. By default, Auto Loader stops the stream when it finds a new column, records the new schema in the schema location, and picks it up after a restart. This is safe but needs a retry policy in your job. Setting
cloudFiles.schemaEvolutionModetorescuekeeps the stream running and routes new columns into_rescued_data.
Replaying from bronze
Replay means re-running downstream logic over rows that bronze already holds. Because bronze is append-only and stamped with _ingested_at, you can select exactly the slice you need.
replay = (
spark.read.table("main.bronze.orders")
.where("_ingested_at >= '2026-11-01' AND _ingested_at < '2026-11-08'")
)
replay.createOrReplaceTempView("orders_replay")You can then run your silver transformation against orders_replay instead of the full bronze table. This works cleanly when the silver write is idempotent. A MERGE keyed on order_id, covered in the silver chapters, gives the same result however many times you run it over the same input.
A few points that trip people up:
- Replay from the table, not from the stream. Re-reading files through Auto Loader would need a new checkpoint and would append duplicate rows to bronze. Reading the bronze table with a batch read avoids this.
- Ingestion time is not event time. A filter on
_ingested_atselects what arrived in a window. It does not select what happened in that window. For late-arriving data, replay by load time and let silver sort out event dates. - Delta time travel is not a replacement. Time travel to an old table version works only within the retention window of the table's history, and
VACUUMremoves old files. Treat it as a safety net for mistakes, not as your replay mechanism.
Retention and deletes
An append-only table that keeps everything grows without limit, and some data cannot be kept forever. Two situations need a plan:
- Cost. Decide how long raw data must stay. If the landing files are kept in object storage, bronze may need to hold only a recent window. If the files are removed after loading, bronze is your only copy of the raw data, and you should keep it much longer.
- Privacy deletions. A request to erase one person's data conflicts with
delta.appendOnly, because the property blocksDELETE. Teams handle this by leaving the property off for tables with personal data and running controlled deletes, or by keeping personal fields out of long-lived bronze tables. Decide this before the table holds data, because changing the approach later means rewriting history.
Common errors
| Symptom | Likely cause | Fix |
|---|---|---|
| Ingestion stops after a source change | A typed schema rejects a new or changed field | Use string columns, rescue mode, or a restart policy |
| Silver cannot pick the latest record | No `_ingested_at` column in bronze | Add load metadata at ingestion |
| Duplicate rows appear after a rerun | Bronze was re-ingested with a new checkpoint | Replay from the table, and keep checkpoints stable |
| A bad value cannot be traced | No `_source_file` column | Capture `_metadata.file_path` at load |
| Data goes missing quietly | Bronze filters or drops "bad" rows | Keep them, and route problems to `_rescued_data` or silver |
| `DELETE` fails on bronze | `delta.appendOnly` is enabled | Remove the property or change the deletion process |
Summary of the layer's contract
Bronze promises that every record the source delivered is stored, traceable to its file and load time, and available to rebuild from. It does not promise clean types, unique keys, or valid values. Those guarantees start in silver. Keeping that boundary clear lets each layer stay simple.
Exercise
A source system starts sending a new field, coupon_code, that your bronze table does not define. Using the Auto Loader defaults described in this chapter, what happens to the stream, and which setting would keep it running while preserving the new field's data?
Show answer
By default, Auto Loader stops the stream when it finds the new column, records the updated schema in the schema location, and picks it up after a restart, so your job needs a retry. Setting cloudFiles.schemaEvolutionMode to rescue keeps the stream running and puts coupon_code into the _rescued_data column as JSON, so the value is not lost. Silver can later promote it to a real column.
Exercise
You find a bug in the silver transformation that has affected the last seven days of data. Which bronze column do you use to select the affected rows, why is re-reading the source files through a new Auto Loader checkpoint the wrong way to replay, and what property of the silver write lets you rerun it safely?
Show answer
Filter on _ingested_at to select the seven-day window. A new checkpoint would reload the files and append duplicate rows into bronze, so replay should batch-read the bronze table instead. The silver write should be idempotent, for example a MERGE keyed on order_id, so running it again over the same input gives the same result.