10. Data quality and contracts
One-liner. Test the properties you rely on, at the boundary and in the marts.
Memorize
- Four checks: schema, freshness, volume, distribution/nullability/uniqueness.
- Contracts: producer guarantees schema + semantics + SLA; violations fail the pipeline, not the dashboard.
- Fail early (ingest) and loudly (alert), not silently downstream.
- Quarantine bad rows instead of dropping them; track a reject rate.
- Reconciliation: row counts and sums between layers catch silent bugs.
- Quality is a pipeline stage, not a quarterly audit.
Trap. Testing only the gold layer — by then a bad join has already polluted every aggregate. Do this. Put a reconciliation check between every pair of layers you own.
Check
A nullable column suddenly becomes 40% null in silver. Which control detects this before dashboards break?
Why
Uniqueness and freshness don't catch a null spike; distribution thresholds at the layer boundary do.