Refinement stages
A Socratic walk-through of refinement stages — reasoned out one step at a time, not lectured.
The question we started with
THE QUESTION #Why copy the same data three times instead of cleaning it once on the way in?
Here is a design that looks wasteful. Data arrives from a payments system. Rather than cleaning it and storing the clean result, a warehouse team lands it untouched in one place, writes a cleaned copy into a second place, and then writes a third copy shaped for the finance dashboard. Three copies of the same facts, three sets of storage bills, three things to keep in step.
The obvious objection is the right place to start: why not clean once, on the way in, and keep only the good version? Storage is not free, and every duplicate is a chance for two numbers to disagree. So what does the extra copying buy that is worth all that?
Reasoning it through
REASONING #Try the single-copy design honestly and see what it costs you. You clean on ingest, and a month later you discover the cleaning rule was wrong — a currency field was assumed to be in cents and was actually in whole units for one merchant. What do you re-run against? The bad rule consumed the only copy of the truth. You can ask the payments system to send it again, but it may only retain thirty days, or it may have mutated the underlying rows since. The unrefined copy is not a duplicate at all; it is the only thing that makes a mistake recoverable.
That is the first argument, and it is about time rather than space. Notice its shape: the raw layer is not there to be queried. It is there so that every later layer is derivable rather than precious.
Now push on the second copy. Why keep a cleaned-but-general layer between the raw landing and the dashboard table? Suppose you skip it. Finance builds its table directly off raw; so does the fraud team; so does the marketing analyst. Each writes its own deduplication, its own timestamp parsing, its own decision about what to do with a null merchant ID. Three teams, three interpretations, and the day someone asks why fraud counts 14,802 transactions and finance counts 14,796, nobody can answer, because the divergence was created independently in three places.
So what is the middle layer really doing? It is where the interpretation everyone shares gets made exactly once — what a row means, which rows are duplicates, what the types are. And what is the third layer doing that the middle one cannot? It is where interpretations that are not shared get made: finance's fiscal calendar, its revenue recognition rule, its particular grain of one row per day per region. Those are not general truths. Baking them into the middle layer would force the fraud team to live with finance's definition of a month.
Does that suggest a principle? Each stage is defined by whose agreement it encodes — nobody's, everybody's, one team's — and stages exist so that a change at one level does not force a change at the others.
The industry's common name for this three-stage version is the medallion architecture, popularised by Databricks, with the layers labelled bronze, silver and gold. The names are branding; the idea long predates them, and plenty of shops call the same thing landing, staging and marts. Three is a convention, not a law — some pipelines honestly need two, and some need four.
The analogy
THE ANALOGY #Think of an archive that receives a shipwreck's cargo. The first room is the wet store: everything comes in exactly as dredged, tagged with where and when it was found, nothing scrubbed, because scrubbing destroys evidence. The second room is conservation: salt removed, fragments joined, each object catalogued in the museum's shared vocabulary so that any curator can find it. The third room is the exhibition: a subset arranged for one story, with labels written for that story's visitors. A second exhibition on a different theme draws from conservation, not from the first exhibition's cases — and if a conservation technique turns out to have been wrong, the wet store still holds what was actually pulled from the seabed.
an archive's objects are physically moved from room to room, whereas each data layer is a derived copy that can be thrown away and rebuilt from the layer above it — which is precisely the property that makes the arrangement affordable.
Clarifying the model
THE MODEL #Two refinements are worth making. The first is that "copy" overstates the cost. The layers are usually not equal in size: raw is the largest, the shared layer often smaller after deduplication, and the presentation tables smaller again because they are aggregated. And because every layer below raw is reproducible, its storage is a cache, not an asset — you can drop and recompute it.
The second correction is about what really goes wrong. The usual failure is not too many layers; it is layers that do not keep their jobs separate. A raw layer that quietly renames columns is no longer a recoverable record. A shared layer that encodes finance's fiscal calendar has become a mart wearing the wrong badge, and the next team will build a fourth layer beside it rather than fight. When people complain that the medallion architecture is bureaucratic, what they have usually met is a pipeline where the boundaries were drawn by habit rather than by whose agreement each transformation needs.
It is also worth saying plainly that this is a convention, not a proven optimum. There is no controlled study showing three layers beat two. The argument for it is the one we reasoned out — recoverability at the bottom, shared meaning in the middle, local meaning at the top — and if your situation does not have all three of those needs, the extra stage is genuine waste.
A picture of it
THE PICTURE #How to readFollow the width of each ribbon, because the widths are the argument. Everything the source sends survives into raw landing at full volume — nothing is discarded before it is recorded. Loss happens only at the shared cleaned layer, where duplicates and unusable rows are split off as their own visible streams rather than vanishing silently. Then notice that the same cleaned stream feeds two marts at full width: the split at that point is not a division of the data but a duplication of it, each mart re-shaping the same rows under a different team's definitions.
What became clearer
WHAT CLEARED #The three copies are not three storages of one thing; they are three different commitments. Raw commits to nothing and so stays replayable. The shared layer commits to what everyone agrees a row means. The mart commits to what one team needs it to mean. Collapsing them saves storage and costs you the ability to fix a mistake, to reconcile two teams' numbers, or to let one team change its definitions without disturbing the rest.
Where to go next
ONWARD #- How incremental processing works between layers, so a refresh reprocesses one partition instead of the whole history.
- Where the streaming equivalent sits, when the raw layer is a retained log rather than a table.
- Whether a lakehouse table format's time travel makes a separate raw layer redundant, or only cheaper.
Key terms
TERMS #| Term | What it means |
|---|---|
| Medallion architecture | a naming convention popularised by Databricks for a bronze (raw), silver (cleaned and conformed) and gold (presentation) layering of a data platform. |
| Raw layer | an immutable record of what a source actually sent, kept so that any later transformation can be re-derived. |
| Conformed layer | the stage where shared meaning is applied once: deduplication, typing, and agreed definitions of an entity. |
| Data mart | a table or set of tables shaped for one team's questions and encoding that team's specific definitions. |
| Idempotent rebuild | re-running a stage over the same input and getting the same output, which is what makes a derived layer disposable. |
Every term the collection defines is gathered in the glossary.