24. ETL: transform before you load
ETL extracts data from its sources, transforms it on the way, and loads only the result. It is the pattern for rules that must already hold when the data arrives: nothing that breaks them ever reaches the target, at the price of not keeping what came in.
The clip extracts the morning's ten claim events at 10:00. On the integration server, before anything is loaded, validation sets aside the claim on a policy that does not exist, the travel claim reported in pounds is converted to euros, and its note with health details is replaced by a marker. Nine rows are loaded into the finance team's staging area; none shows health details. Last, the price: the raw events are not kept, so a changed rule means extracting from the source again.
The intuition: check the parcel before it goes through the door
Harbour Mutual's finance team keeps a staging area for the claims it will book at month end. The whole team reads it, and every figure in it is summed into the ledger. So the team has rules about what may arrive there: no claim on a policy that does not exist, every amount in euros, and never a customer's health details, which the claims portal sometimes carries in a free-text note.
The simplest way to keep those rules is to apply them before the door: collect the morning's claims, check and clean them somewhere else, and carry in only what passed. Whoever reads the staging area can then trust every row in it without knowing what the source looked like. That is ETL: extract, transform, load, in that order.
How it works, step by step
Extract reads the data from the source: here, the claims portal's log of claim events, read by the batch that runs at 10:00. A batch extract is defined by a watermark of its own kind, the position or time it read up to last time, so each run takes only what is new.
Transform applies the rules on an integration engine outside the target: validating each row against reference data (does the policy exist?), converting and deriving values (pounds to euros at the day's rate), and removing or masking what the target's readers may not see. Rows that fail a rule are set aside in a reject or quarantine file with the reason, for someone to correct.
Load writes the rows that passed into the target in one step, so readers see the whole batch or none of it. A load is made safe to repeat by writing on a key (here the event's id) rather than appending: a run that fails half-way can then simply run again.
The question ETL answers is which rules must run before the target. A rule belongs before the target when a row that breaks it must never be seen by anyone who reads the target. Masking health details is such a rule; so is refusing a claim on a policy that does not exist when the target is the ledger's staging. Converting currency is not: it only shapes a number for a report, and could run later, as long as it runs before anyone sums.
| Rule | What it does | Before the target? | Why |
|---|---|---|---|
| Validate the policy | A claim whose policy the policy system does not know is set aside, not loaded. | yes | The ledger's staging is read by the whole finance team: a claim on a policy that does not exist must never be counted. |
| Convert to euros | An amount reported in pounds is converted at the day's rate. | no | Converting only shapes the number for a report; it can run in the target, as long as it runs before anyone sums. |
| Mask health details | A note with health details is replaced by a marker. | yes | Health details are special-category data: nobody who reads the target may see them, so they must not arrive there. |
By hand
Take the ten claim events of the morning and apply the three rules as ETL does, one at a time, before anything is loaded.
| Event | Claim | Policy | Reported | Reached the log | Amount | Note |
|---|---|---|---|---|---|---|
| E01 | C-201 | P-1001 | 09:01:40 | 09:02:10 | €1,200 | – |
| E02 | C-202 | P-1002 | 09:04 | 09:04:50 | €2,400 | – |
| E03 | C-203 | P-1003 | 09:06:30 | 09:07:45 | £800 | health details |
| E04 | C-204 | P-9999 | 09:09 | 09:09:40 | €650 | – |
| E06 | C-206 | P-1006 | 09:14:20 | 09:15:05 | €950 | – |
| E07 | C-207 | P-1007 | 09:14:50 | 09:15:12 | €4,200 | – |
| E08 | C-208 | P-1008 | 09:15 | 09:15:20 | €700 | – |
| E09 | C-209 | P-1009 | 09:18:30 | 09:19:10 | €1,500 | – |
| E05 | C-205 | P-1005 | 09:12:10 | 09:21:30 | €3,100 | – |
| E10 | C-210 | P-1010 | 09:24 | 09:25:40 | €2,600 | – |
- Validate: which event names a policy that does not exist?
Predict the result, then check it
E04, on policy P-9999: it is set aside with its reason, and 9 events go on. - Convert: E03 was reported as £800; at the day's rate of 1.15 euros to the pound, what is it in euros?
Predict the result, then check it
£800 × 1.15 = €920. - Mask: which row carries health details, and what reaches the target instead?
Predict the result, then check it
E03: its note becomes the marker "[withheld: health details]". - Load: how many rows reach the target, and what is their total?
Predict the result, then check it
9 rows: €17,570. - Latency: the batch commits at 10:05. How long did the first event, which reached the log at 09:02:10, wait to be readable?
Predict the result, then check it
62.8 minutes; on average the ten waited 51.4 minutes.
What you found: The target holds 9 rows totalling €17,570, none of them with health details; 1 event waits in the reject file. And nothing else: the raw events are not in the target.
- Extract only what is new since the last run
- Without it: Every run reads the whole source again, and a busy system is read for hours.
- Validate against reference data before the load
- Without it: A claim on a policy that does not exist is summed into the month's figures before anyone notices.
- Set rejects aside with their reason
- Without it: A failed row disappears, and nobody can correct it or explain the gap between the source and the target.
- Mask on the way, not in the target
- Without it: For as long as the row sits in the target, every reader of it can see the health details.
- Load on a key, in one step
- Without it: A run that fails half-way leaves half a batch, and running it again counts the first half twice.
- ETL is old-fashioned; ELT has replaced it.
- In fact: The order follows the rule, not the decade. When readers of the target must never see a row that breaks a rule, the rule runs before the target, whatever the tools.
- All transformations belong before the load.
- In fact: Only the ones every reader depends on. Of the three rules here, 2 must run before the target; converting currency could run later.
- A batch that runs once a day is always a day late.
- In fact: It is as late as its schedule. Here the ten events wait 51.4 minutes on average because the batch runs at 10:00; a batch every hour would cut that.
When it fits, and when it does not
- Fits: a target whose readers cannot be kept from any row in it (a ledger's staging, a file sent to a partner), rules that are stable, and a freshness of hours or a day.
- Fits: sources that must not be read often, and data that must be reduced (masked, aggregated) before it leaves its owner's control.
- Does not fit: rules that change often and must be applied to history, because the raw input is gone; data needed within minutes; very large volumes where the transformation is cheaper inside the target platform (page 25).
Design notes
Keep the reject file as data with an owner, not a log line: someone corrects each rejected row and sends it again. Make every load repeatable by writing on a key. Record which rules ran, in which version, for each batch: that is the lineage (page 12) that lets a reader of the target trust it without seeing the source.
Why it matters
In the merger, both companies' claims flow into one finance staging area. Deciding which rules run before it is deciding what the finance team can take for granted, and what the auditors will ask to see. ETL is the honest answer whenever the answer is "every reader, always".
On Azure (checked against Microsoft Learn on 24 October 2026)
- Azure Data Factory runs the batch: a pipeline on a schedule, a copy activity to extract, and a mapping data flow for the transformations, which Data Factory runs on Spark clusters it manages.
- Microsoft Fabric offers the same in Data Factory for Fabric, with Dataflow Gen2 for the transformations.
Where it goes wrong
- Rejects nobody reads. The reject file grows, and the target is quietly short of claims every month.
- Rules buried in the tool. A rule nobody can find is a rule nobody can review or change with confidence.
- Append on retry. A failed run run again loads the first half twice.
- No raw copy anywhere. A changed rule needs history the source no longer has.
- Say what extract, transform and load each do, and in what order.
- Decide which rules must run before a target, by asking who reads it.
- Work a small batch through validation, conversion and masking by hand.
- Explain what ETL gives up by not keeping the raw input.
Check yourself
Choose an answer to each question, then press Check.
Sources
The works this page draws on, summarised in its own words rather than quoted. Read them for the full argument.
- R. Kimball and J. Caserta, The Data Warehouse ETL Toolkit (Wiley, 2004)The subsystems of extract, transform and load, rejects and repeatable loads.
- M. Kleppmann, Designing Data-Intensive Applications (O'Reilly, 2017), chapter 10Batch processing and why repeatable, deterministic jobs are easy to recover.
- Microsoft Learn: Mapping data flows in Azure Data FactoryVisually designed transformations run on Spark clusters that Data Factory manages.
Practise it
The chapters that put this theory to work on Harbour Mutual and Kestrel:
- Chapter 26: The medallion architecture 1: the layers
- Chapter 29: Integration patterns: batch, streaming, APIs and sharing
- Chapter 31: Pipeline patterns: choosing and combining
The tools to try it in:
- Pipeline patterns lab · Run the same claim events through eight pipeline patterns and see latency, overhead, a consumer failing, a delivery repeated and a logic change replayed.
- Quality workbench · Write quality rules, set thresholds, inject defects, and see the scores per dimension and per domain.
Terms taught here: ETL