Every report rests on assumptions about the data: ids are unique, every order line has an order, prices are positive, emails are filled in. Data quality checks turn each assumption into a query that returns the rows that break it. An empty result means the check passes.
The four checks every table gets:
- Unique keys:
GROUP BY key HAVING COUNT(*) > 1.
- No orphans: child rows whose parent is missing (
LEFT JOIN ... WHERE parent IS NULL, or NOT EXISTS).
- Valid values: ranges and allowed lists (
WHERE price <= 0 OR cost > price).
- Completeness: the share of NULLs in columns that should be filled.
Tools such as dbt run checks like these on every load and stop the pipeline when one fails. Writing them as plain queries works everywhere.