Data Quality, Testing & Contracts
You'll be able to:
You can define a data-quality strategy that catches silent breakage before it reaches a dashboard, and explain why an upstream schema change is often more damaging than a bug in analytics code.
A revenue dashboard was wrong for six weeks. It was not wildly wrong — it was about eleven percent low, which is well inside the range where a number still looks plausible. Nobody noticed until a finance reconciliation forced the comparison. The pipeline had succeeded every single night. This is the central difficulty of data quality: the absence of errors tells you nothing.
The categories of test worth writing
A practical data-quality suite covers five kinds of check. Uniqueness and not-null on primary keys catch structural corruption. Freshness asserts that data arrived at all, and recently. Referential integrity catches orphaned foreign keys — orders pointing at customers that do not exist. Distribution checks catch values that are structurally valid but statistically implausible. Business invariants encode domain truths: refunds never exceed the original charge, a subscription cannot end before it begins.
Here is what experienced practitioners know and newcomers consistently get backwards: the single highest-value test is almost always freshness, and it is the cheapest one to write. The overwhelming majority of real incidents are not "the number is subtly wrong" but "the data stopped arriving and the chart kept showing the last good value." Teams routinely build elaborate correctness assertions while having no alarm for a pipeline that simply stopped.
Why upstream schema changes hurt more than analytics bugs
An analytics bug lives in code you own. It is version-controlled, reviewed, tested, and you can roll it back in minutes. An upstream schema change arrives unannounced, from a team with no visibility into your dependency, and every downstream consumer inherits it simultaneously and silently.
This asymmetry is what data contracts address. A contract is an explicit agreement at the producer boundary covering schema, semantics, and freshness guarantees — enforced in the producer's CI, so a breaking change fails their build rather than your dashboard. It moves detection from hours-after-damage to before-merge.
Failure modes
Alert fatigue — two hundred tests, thirty failing on any given day, most of them known and unactioned. Signal: a dedicated alerts channel that everyone has muted, and incidents that are discovered by executives rather than by monitoring.
Freshness blind spot — the pipeline fails silently or an upstream export stops, and the dashboard confidently displays stale numbers. Signal: a chart that flatlines at exactly the last good value, holding a perfectly constant line for days.
Testing only the final mart — every assertion runs at the end of the pipeline, so you learn that something broke but nothing about where. Signal: incident triage that consistently takes hours and begins with bisecting the DAG by hand.
Seasonality-blind distribution tests — a static threshold on daily volume fires every weekend because weekend traffic is legitimately half of weekday traffic. Signal: an alert that recurs on a predictable calendar rhythm and is routinely dismissed.
Explaining this to stakeholders
On tests versus contracts: tests are smoke detectors, and they are essential — but a contract is the building code that stops the house being wired badly in the first place. One tells you there is a fire; the other reduces how often fires start.
On why a passing pipeline proves nothing: the pipeline reports that it ran, not that it was right. A delivery van completing its route does not mean the packages were in it.
On the value of freshness alerts: the most common failure is not a wrong answer, it is yesterday's answer presented as today's. That is also the easiest failure to catch, which is why it should be the first alarm anyone builds.
Curated Materials
1hThe deep work happens here — the lesson is your briefing.
Live on aiqbench
This lesson's subject on the rest of the site, today.
In the news, last 30 days
- RoboIntervene: A Dataset for Learning When to Step In and How to Recover Robot Policy ExecutionarXiv ·
- HuGEM: A Humanoid Manipulation Dataset with Paired Goal- and Execution-Level InstructionsarXiv ·
- Human-Agent Forensics and Recovery of an Extreme-Scale Climate DatasetarXiv ·
Test your knowledge
5 questions in 100 seconds, on a page of its own. Read everything above first.
Test your knowledge →Module Mission
20–30 minFor a daily revenue metric, list 5 tests you would run: uniqueness, freshness, referential integrity, distribution, and one business-logic invariant. For each, describe what triggers the alert and who gets paged.
Loading your work…