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.
| Blind faults caught3 vs 4 of 10layer checks against day-level checks (version 3; version 2 caught 3); 7 of 10 together | Damaged 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 them | False alarms0every check, on 4 clean loads batched different ways | Built 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
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.
Show the data
| Check family | Caught | Faults |
|---|---|---|
| Any layer check | 3 | Flags as 1 and 0, Trip IDs reused, Corrections counted twice |
| Control totals | 3 | Flags as 1 and 0, Trip IDs reused, Corrections counted twice |
| Watermark and restatement | 0 | none |
| Schema contract | 1 | Flags as 1 and 0 |
| Idempotency | 2 | Trip IDs reused, Corrections counted twice |
| Backfill scope | 0 | none |
| Rebuild matches | 2 | Trip IDs reused, Corrections counted twice |
| Any day-level check | 4 | Last file never sent, Kilometres as miles, Trips stamped a day late, Missing fare written as -1 |
| Arrival window (version 3) | 1 | Trips stamped a day late |
| Freshness | 1 | Last file never sent |
| No negative values | 1 | Missing fare written as -1 |
| Units (distance pair) | 1 | Kilometres as miles |
| Fault | What changed | Layer checks | Day-level, version 3 | Published numbers | After recovery |
|---|---|---|---|---|---|
| Last file never sent | The January 31 file never arrives. | Missed | Caught: freshness | Wrong on 1 day | Not run: not caught by a layer check |
| File cut short | January 18 arrives without its last 40 rows, and the batch records the shorter count. | Missed | Missed | Wrong on 1 day | Not run: not caught by a layer check |
| Money in cents | Fares, tips, charges and totals for January 11 to 13 arrive 100 times too large. | Missed | Missed | Wrong on 3 days | Not run: not caught by a layer check |
| Flags as 1 and 0 | The shared-trip flags of January 22 and 23 arrive as 1 and 0, so both files are parked. | Caught: control totals, schema contract | Missed | Wrong on 2 days | Not 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 miles | Distances for January 25 to 27 arrive in kilometres under the miles name. | Missed | Caught: units (distance pair) | Wrong on 3 days | Not run: not caught by a layer check |
| Trip IDs reused | 30 January 9 trips arrive under January 8 trip IDs and overwrite those rows in the clean table. | Caught: control totals, idempotency, rebuild matches | Missed | Right | Made worse: the published numbers were right, but the rebuild trusts the trip ID, so January 8 lost 30 trips |
| Corrections counted twice | 30 corrected January 16 durations arrive in a second batch before the day closes. | Caught: control totals, idempotency, rebuild matches | Missed | Wrong on 1 day | Trip counts restored; January 16 durations keep the corrections (1,800 seconds), which the clean month does not have |
| Fare and tip swapped | On January 5 the fare and tip fields trade places. | Missed | Missed | Wrong on 1 day | Not run: not caught by a layer check |
| Trips stamped a day late | 25 January 28 trips arrive stamped January 29. | Missed | Caught: arrival window (version 3) | Wrong on 2 days | Not run: not caught by a layer check |
| Missing fare written as -1 | Missing fares on January 24 and 25 arrive as -1; in this sample that touched one trip. | Missed | Caught: no negative values | Wrong on 1 day | Not 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
| Check | Needs | Catches |
|---|---|---|
| Control totals | A 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 restatement | A publication log (which day was published when) and a restatement log with a reason per change. | Late rows silently dropped or absorbed. |
| Schema contract | A schema registry, and a column descriptor sent with every file. | Renamed, retyped or added columns, before they park or corrupt a load. |
| Idempotency | The 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 scope | Every 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 matches | Enough 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
- 10 blind faults from one independent author in one run, and 8 of my own, on one month of 10,000 public trips. The counts describe these faults, not a catch rate.
- The pipeline is one design: a streaming-style published table that adds each batch's totals. A pipeline that recomputes every published day from the cleaned table would not double-count replays, and would lean less on the idempotency and control-total checks.
- The blind faults lean towards values changed at the source (cents, kilometres, swapped fields). Layer checks compare layers with each other, so a fault already in the landing table passes them by design.
- The truth is always the clean month. One fault carried corrections a real team might accept, and the score counts them as a difference.
- The day-level checks read the cleaned table, not the published one, and the runbook does not map new formats. Both are choices, declared before any fault ran.
- A small local lakehouse: the open-source deltalake package and DuckDB, no Spark cluster.
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
| Fault | What changed | Layer checks | Day-level, version 3 | Published numbers | After the declared recovery |
|---|---|---|---|---|---|
| Late rows past the watermark | The last 60 January 24 rows arrive after the day was published. | Caught: control totals, rebuild matches, watermark and restatement | Caught: arrival window (version 3) | Wrong on 1 day | Restored |
| Renamed column | From January 26 the fare column arrives as fare_amount. | Caught: control totals, schema contract | Caught: freshness, freshness (second test) | Wrong on 6 days | Restored |
| Widened type | From January 29 trip durations arrive as decimals. | Caught: control totals, schema contract | Caught: freshness, freshness (second test) | Wrong on 3 days | Restored |
| New column | From January 28 a payment type column is appended. | Caught: schema contract | Missed | Right | Nothing to restore; still right |
| Backfill counted twice | The stream is re-run for January 8 to 14 without clearing the published table. | Caught: control totals, idempotency, rebuild matches | Caught: arrival window (version 3) | Wrong on 7 days | Restored |
| Backfill with new logic | A job rewrites January 15 to 21 with fares taken from totals, and its filter also rewrites January 22. | Caught: backfill scope, control totals, rebuild matches | Missed | Wrong on 8 days | Restored |
| Replay after an outage | Two January 30 micro-batches are delivered again, out of order, before the day closes. | Caught: control totals, idempotency, rebuild matches | Missed | Wrong on 1 day | Restored |
| Partial restore | The clean table is restored to before January 26 and the published table is left as it was. | Caught: control totals | Missed | Right | Nothing 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.