
What really happened
Friday's cleanup added a dedup to the orders fact table: keep the latest row per key. The key was order_id. It should have been order_line_id.
Every order with more than one line collapsed to a single line. About 63% of the revenue vanished, and no test failed, because the uniqueness test on order_id was now perfectly true.
Uniqueness tests catch duplicates. They can't see rows that are gone. Only counting against the source can.
The lesson: Count against the source.
Run the one-word bug
A fact table at order-line grain ends with a dedup. Pick the key it partitions by, then run it. The query runs in your browser on DuckDB with 5,391 synthetic order lines.
qualify row_number() over (
partition by l.
order by o.updated_at desc
) = 1Source, tests and the agent skill: github.com/Kevin-yyuan/dbt-reconcile
A new bug every episode.
Go deeper
- The code: dbt-reconcileThe tests that catch this bug, plus an agent skill that runs the review. On GitHub.
- The articleThe same bug, written up for data teams. On LinkedIn.
- Episode 2: Yesterday's sales changed overnight. Nobody touched anything.Define the day once. Close it on purpose.
- Episode 3: We hit 112% of target. Then we checked.Know the grain on both sides.






