Skip to content

Diogo TravassosData leadership · Analytics · Decision-making

Public dataSynthetic faults

Data quality scorecard · pipeline recovery

On one month of public trip data, layer checks caught 3 of 10 pipeline faults written blind, against 4 of 10 for the day-level checks; one generic recovery runbook restored 0 of the 2 damaged faults it ran on and made 1 healthy result worse.

The two kinds of check caught different faults: 7 of 10 together, with no fault caught by both. Layer checks see how rows move between tables, such as a parked file, a reused trip ID or a correction counted twice. Day-level checks see what the rows say, such as a missing last day, kilometres in a miles field or a negative fare. Three faults got past both: file cut short, money in cents and fare and tip swapped. On the eight faults I wrote myself with the checks in view, the layer checks caught 8, and recoveries written for each fault put back all 6 that had changed the published numbers, a self-test.

Key figures
Blind faults caught3 vs 4 of 10layer checks against day-level checks (version 3; version 2 caught 3); 7 of 10 togetherDamaged faults restored0 of 2of the damaged blind faults the layer checks caught, by one runbook for every fault (rebuild from the landing table, restate). It leaves parked files parked, so one stays unpublished until an engineer maps the new format; one got its trip counts back but kept the source's own duration corrections, which the clean month lacks; and on one whose published numbers were right, it trusted a reused trip ID and broke themFalse alarms0every check, on 4 clean loads batched different waysBuilt with the faults in view8/8caught by layer checks; a recovery written for each fault put back all 6 that had changed the published numbers; a self-test

Main limitation Ten faults written blind and eight of my own, on one month of public trip data in a small local lakehouse. The counts describe these faults, not how often the checks would catch faults in production.

The ten blind faults

Layer checks and day-level checks caught different blind faults: 3 and 4 of 10, 7 together.

Blind faults caught out of 10, by check family. The first bar in each group counts a fault once however many of its checks fired. Version 2 of the day-level checks caught 3; version 3 adds the arrival window.

Blind faults caught, by check familyAny layer check: 3 of 10; Control totals: 3 of 10; Watermark and restatement: 0 of 10; Schema contract: 1 of 10; Idempotency: 2 of 10; Backfill scope: 0 of 10; Rebuild matches: 2 of 10; Any day-level check: 4 of 10; Arrival window (version 3): 1 of 10; Freshness: 1 of 10; No negative values: 1 of 10; Units (distance pair): 1 of 10.0246810LAYER CHECKSAny layer check: caught 3 of 10 blind faults (Flags as 1 and 0; Trip IDs reused; Corrections counted twice)Any layer check3 of 10Control totals: caught 3 of 10 blind faults (Flags as 1 and 0; Trip IDs reused; Corrections counted twice)Control totals3 of 10Watermark and restatement: caught 0 of 10 blind faultsWatermark and restatement0 of 10Schema contract: caught 1 of 10 blind faults (Flags as 1 and 0)Schema contract1 of 10Idempotency: caught 2 of 10 blind faults (Trip IDs reused; Corrections counted twice)Idempotency2 of 10Backfill scope: caught 0 of 10 blind faultsBackfill scope0 of 10Rebuild matches: caught 2 of 10 blind faults (Trip IDs reused; Corrections counted twice)Rebuild matches2 of 10DAY-LEVEL CHECKS, VERSION 3Any day-level check: caught 4 of 10 blind faults (Last file never sent; Kilometres as miles; Trips stamped a day late; Missing fare written as -1)Any day-level check4 of 10Arrival window (version 3): caught 1 of 10 blind faults (Trips stamped a day late)Arrival window (version 3)1 of 10Freshness: caught 1 of 10 blind faults (Last file never sent)Freshness1 of 10No negative values: caught 1 of 10 blind faults (Missing fare written as -1)No negative values1 of 10Units (distance pair): caught 1 of 10 blind faults (Kilometres as miles)Units (distance pair)1 of 10
Show the data
Blind faults caught by each check family
Check familyCaughtFaults
Any layer check3Flags as 1 and 0, Trip IDs reused, Corrections counted twice
Control totals3Flags as 1 and 0, Trip IDs reused, Corrections counted twice
Watermark and restatement0none
Schema contract1Flags as 1 and 0
Idempotency2Trip IDs reused, Corrections counted twice
Backfill scope0none
Rebuild matches2Trip IDs reused, Corrections counted twice
Any day-level check4Last file never sent, Kilometres as miles, Trips stamped a day late, Missing fare written as -1
Arrival window (version 3)1Trips stamped a day late
Freshness1Last file never sent
No negative values1Missing fare written as -1
Units (distance pair)1Kilometres as miles
Each blind fault: the checks that caught it, the published numbers at the clock, and after the declared runbook
FaultWhat changedLayer checksDay-level, version 3Published numbersAfter recovery
Last file never sentThe January 31 file never arrives.MissedCaught: freshnessWrong on 1 dayNot run: not caught by a layer check
File cut shortJanuary 18 arrives without its last 40 rows, and the batch records the shorter count.MissedMissedWrong on 1 dayNot run: not caught by a layer check
Money in centsFares, tips, charges and totals for January 11 to 13 arrive 100 times too large.MissedMissedWrong on 3 daysNot run: not caught by a layer check
Flags as 1 and 0The shared-trip flags of January 22 and 23 arrive as 1 and 0, so both files are parked.Caught: control totals, schema contractMissedWrong on 2 daysNot restored: 2 parked files need a schema mapping, which the runbook leaves to an engineer, so January 22 and January 23 stay unpublished
Kilometres as milesDistances for January 25 to 27 arrive in kilometres under the miles name.MissedCaught: units (distance pair)Wrong on 3 daysNot run: not caught by a layer check
Trip IDs reused30 January 9 trips arrive under January 8 trip IDs and overwrite those rows in the clean table.Caught: control totals, idempotency, rebuild matchesMissedRightMade worse: the published numbers were right, but the rebuild trusts the trip ID, so January 8 lost 30 trips
Corrections counted twice30 corrected January 16 durations arrive in a second batch before the day closes.Caught: control totals, idempotency, rebuild matchesMissedWrong on 1 dayTrip counts restored; January 16 durations keep the corrections (1,800 seconds), which the clean month does not have
Fare and tip swappedOn January 5 the fare and tip fields trade places.MissedMissedWrong on 1 dayNot run: not caught by a layer check
Trips stamped a day late25 January 28 trips arrive stamped January 29.MissedCaught: arrival window (version 3)Wrong on 2 daysNot run: not caught by a layer check
Missing fare written as -1Missing fares on January 24 and 25 arrive as -1; in this sample that touched one trip.MissedCaught: no negative valuesWrong on 1 dayNot run: not caught by a layer check

Version 2 caught the same faults as version 3 except trips stamped a day late, which only the arrival window saw.

One day-level result needs a note. On flags as 1 and 0, January 22 and 23 never loaded, so the anomaly check had no full two-week baseline for the latest day and the day-level trust score fell to 20, the cap for missing evidence, with no check failing. The rule declared before the run is that a fault counts as caught only when a check fails, so it counts as missed here; a team watching the score would still have seen it drop. My own partial-restore fault, which lost two days of the cleaned table, did the same.

The recovery result is the hard one. One generic runbook was applied to every blind fault the layer checks caught: rebuild the cleaned table from the landing table and restate any day that differs. That works when the landing table holds the truth. It did not here. It leaves parked files parked by design, so one fault needs a person to map a new format; one carried genuine corrections, which count as not restored only because the truth is the clean month; and one reused trip IDs, so the rebuild kept the wrong trips and broke published numbers that were right. A rebuild is only as good as the keys and formats it trusts. The eight of eight on my own faults used a recovery written for each fault.

In plain words

The scorecard checks the trip table a dashboard reads, one day at a time. Many data teams land data in layers: a raw landing table that keeps every file as it arrived (bronze), a cleaned table with one row per trip (silver), and the published daily numbers (gold). Faults also happen between the layers: a day arrives after its numbers were published, a column is renamed upstream, a backfill runs twice, a stream replays after an outage, or a restore goes too far back. The rows can look fine while the published numbers are wrong.

I loaded the same public month into real Delta tables, added six checks that compare the layers and the load history, and declared a recovery for each fault I wrote. An independent author, who saw the pipeline's design but never the checks, then wrote ten pipeline faults a real team could hit. Each fault was scored twice: did any check catch it, and after recovery, were the published numbers back to the clean month's?

Control totals
Row counts and sums per day agree from bronze to silver to gold.
Watermark
The latest published day. Rows for an earlier day are late.
Restatement
Changing a published day on purpose, with a record of why.
Idempotency
Delivering the same batch twice changes nothing.
Backfill
Re-running past days through the pipeline.
Day-level checks
The scorecard's checks, versions 2 and 3, run on the cleaned table.

What each check needs from a team

The records a pipeline has to keep before these checks can run
CheckNeedsCatches
Control totalsA batch ID and load time on every landed row, and a landing table that is never updated in place.Rows lost or counted twice between layers.
Watermark and restatementA publication log (which day was published when) and a restatement log with a reason per change.Late rows silently dropped or absorbed.
Schema contractA schema registry, and a column descriptor sent with every file.Renamed, retyped or added columns, before they park or corrupt a load.
IdempotencyThe trip key on every row, and a record of which keys each batch changed in the published table.Replays and re-runs that add the same rows again.
Backfill scopeEvery backfill or batch job recorded with its declared window and the table versions before and after.Jobs that rewrite days they were not meant to.
Rebuild matchesEnough history in the landing table to rebuild every published day.Published numbers that no longer follow from the data.

None of this needs a large platform. Delta tables give the version history and time travel for free, and the logs are a few small tables. I have not run these on Spark; the checks read table versions and logs, so I expect the idea to carry over. I would add them in this order: control totals first, because they need only a batch ID and they caught the most here, then the rebuild comparison, then the history checks as backfills and replays become routine.

The next part, pipeline cost, measures what each layout of this pipeline costs to run and to query, and what the cheaper layouts give up. A further part, lineage and SLOs, follows a change from the source down to the dashboards and measures which checks would have stopped it.

Limits

How this was checked

On this part, the first full run gave the day-level checks the clean table after recovery instead of before it, which hid both schema faults from them. A look at the row counts caught it: the renamed-column run handed the checks the whole month, though six of its days had never loaded. The table is now captured before any recovery, and every result here comes from a clean rerun.

Two more things the record shows. The late-data fault I declared assumed 300 trips on January 24, but the day has 308, so the last 60 arrive late and the other 248 on time; that reading is written down and changed no check. And development runs of three scenarios came before the full run, with the same check results.

Use this at your company

To test a pipeline of your own the same way, paste this prompt into an AI assistant that can query your warehouse.

This method comes from Diogo Travassos's study "Data quality scorecard: pipeline recovery" (https://diogotravassos.dev/data-quality-scorecard/pipeline-recovery.html). If you can open links, read it first: it works the method through end to end and shows the checks that caught mistakes. The steps below stand on their own if you can't.

Help me test whether my pipeline's checks catch faults in how data moves between layers, not only in what the rows say, and whether our recovery puts the published numbers back.

Data you need from me: the raw landing table with a batch ID and load time on every row, the cleaned table keyed on a row ID, the published daily table, and a log of loads, backfills and restores covering at least a month.

Method:
1. Write control totals per layer: row counts and key sums per day from the landing table to the cleaned table to the published table, allowing only for the deduplication you expect.
2. Add four checks on the load history: late rows for a day already published need a restatement record; every file matches a registered schema; a batch delivered again leaves the published table unchanged; a backfill changes nothing outside its declared window.
3. Rebuild the published table from the landing table and compare it with what is published, per day and metric.
4. Before trusting the checks, have someone who has not seen them write 10 realistic pipeline faults: late files, renamed or retyped columns, a backfill run twice, a replay after an outage, a restore that goes too far back.

Checks before trusting the answer:
- Run every check on clean loads batched different ways (shuffled rows, micro-batches, two days in one load) and confirm none fires.
- Count the blind faults caught by the layer checks and by your existing day-level checks separately, and list the faults neither catches.
- After each recovery, compare the published numbers with a clean rebuild per day and metric, and say which were restored.

Report back: which faults each kind of check caught, which recoveries restored the published numbers, the false alarms, and the limits: how many faults you tested, on how much data, and that the count is not a catch rate for production.

In your report, say which study you followed and link it: https://diogotravassos.dev/data-quality-scorecard/pipeline-recovery.html

Method and checks

The layout and the pipeline under test

Bronze keeps every delivered file as text with its batch ID, load time, source file and schema version, plus a manifest of each file's column descriptor and day markers. Silver conforms each batch strictly (a missing column or a value that does not parse parks the whole file) and merges it on trip ID. Gold adds each batch's totals for days after the watermark, and a day is published when its end-of-day marker arrives. Each file loads at 01:00 the next day; the clock is 06:00 on February 1, 2024.

Tools: deltalake 1.6.6 (Delta tables, no Spark), DuckDB 1.5.6, pyarrow 26.0.0, and for the day-level checks dbt-core 1.12.5 with dbt-duckdb 1.11.0.

The six checks and the tolerance

Counts must match exactly; fare, mile and second sums within 0.01 per day. Control totals compare bronze (one row per trip ID from its latest load) with silver, and silver with gold. Watermark and restatement require a restatement record for any row that lands for a day already published. Schema contract compares each file's descriptor and values with a registered version. Idempotency fails when a batch that re-delivers known trip IDs changes gold. Backfill scope fails when a job changes a gold day outside its declared window. Rebuild matches compares gold with gold rebuilt from bronze. A fault counts as caught when any check fails.

False alarms

The same rows, loaded four ways:

  • The clean schedule: one batch per day at 01:00 the next day.
  • The same batches with rows shuffled inside each batch (fixed seed).
  • Each day as three micro-batches of thirds at 01:00, 01:10 and 01:20, the marker on the last.
  • January 10 and January 11 load together in one batch at 01:00 on January 12.

No layer check and no version 2 or 3 check fired on any of the 4.

My own faults, written with the checks in view
8 faults declared before any run: a self-test
FaultWhat changedLayer checksDay-level, version 3Published numbersAfter the declared recovery
Late rows past the watermarkThe last 60 January 24 rows arrive after the day was published.Caught: control totals, rebuild matches, watermark and restatementCaught: arrival window (version 3)Wrong on 1 dayRestored
Renamed columnFrom January 26 the fare column arrives as fare_amount.Caught: control totals, schema contractCaught: freshness, freshness (second test)Wrong on 6 daysRestored
Widened typeFrom January 29 trip durations arrive as decimals.Caught: control totals, schema contractCaught: freshness, freshness (second test)Wrong on 3 daysRestored
New columnFrom January 28 a payment type column is appended.Caught: schema contractMissedRightNothing to restore; still right
Backfill counted twiceThe stream is re-run for January 8 to 14 without clearing the published table.Caught: control totals, idempotency, rebuild matchesCaught: arrival window (version 3)Wrong on 7 daysRestored
Backfill with new logicA job rewrites January 15 to 21 with fares taken from totals, and its filter also rewrites January 22.Caught: backfill scope, control totals, rebuild matchesMissedWrong on 8 daysRestored
Replay after an outageTwo January 30 micro-batches are delivered again, out of order, before the day closes.Caught: control totals, idempotency, rebuild matchesMissedWrong on 1 dayRestored
Partial restoreThe clean table is restored to before January 26 and the published table is left as it was.Caught: control totalsMissedRightNothing to restore; still right

Version 2 caught 2 of these and version 3 caught 4. Each fault had its own declared recovery: restate the day from silver, register the new schema and reload the parked files, restore gold to its version before a bad job (time travel), or merge the lost batches back.

How the blind faults were written

The author is independent of the checks: given only the pipeline's design and the schemas, it never saw them. Its prompt held the layout and the pipeline's design (a strict conform that parks a whole file, MERGE on trip_id, gold adding each batch's totals for days after the watermark), the registered schema, three sample rows and my eight faults as already written. It held no check. Each fault was implemented literally, with every reading of an ambiguous step written down before the run, and none was changed after. For the blind faults one runbook applies, declared before they existed: rebuild silver from bronze with the registered schemas, then restate every gold day that differs. The design file and run record of this round are kept out of these downloads, so it cannot be re-run from them alone; the steps above describe it.