Theory · Page 24 of 34 · Pipeline patterns

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.

Ten claim events transformed on the way in
Playback speed

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.

Remember ETL runs the rules before the target, so nothing that breaks them is ever in it; it keeps the result, not the input.

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.

The three rules, and whether each must run before the target
RuleWhat it doesBefore the target?Why
Validate the policyA claim whose policy the policy system does not know is set aside, not loaded.yesThe 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 eurosAn amount reported in pounds is converted at the day's rate.noConverting only shapes the number for a report; it can run in the target, as long as it runs before anyone sums.
Mask health detailsA note with health details is replaced by a marker.yesHealth 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.

The morning's ten claim events
EventClaimPolicyReportedReached the logAmountNote
E01C-201P-100109:01:4009:02:10€1,200–
E02C-202P-100209:0409:04:50€2,400–
E03C-203P-100309:06:3009:07:45£800health details
E04C-204P-999909:0909:09:40€650–
E06C-206P-100609:14:2009:15:05€950–
E07C-207P-100709:14:5009:15:12€4,200–
E08C-208P-100809:1509:15:20€700–
E09C-209P-100909:18:3009:19:10€1,500–
E05C-205P-100509:12:1009:21:30€3,100–
E10C-210P-101009:2409:25:40€2,600–
  1. 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.
  2. 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.
  3. 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]".
  4. Load: how many rows reach the target, and what is their total?
    Predict the result, then check it 9 rows: €17,570.
  5. 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.

Why this step
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.
People often think…
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.
You can now…
  • 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.

1. Which of the three rules could run inside the target without anyone who reads it seeing a broken row?
2. How many rows does the morning's ETL load?
3. A rule changes and must be applied to last month's claims. What does ETL need?
Answer every question first.

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:

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

An unhandled error has occurred. Reload 🗙

Reconnecting…

Your connection to the Cloud Data Architecture Lab dropped, probably a Wi-Fi blip. Hold on while it reconnects.

The connection could not be restored. The page will reload in a few seconds.