Data quality and testing
Data Warehousing · 13 questions
Short notes
Key idea
Bad data that reaches a dashboard costs trust. Test data like code: check each table's assumptions automatically after every load and stop or alert when they fail.
Syntax
Common checks:
- Not null on keys; unique primary keys.
- Accepted values (status in new/paid/shipped).
- Referential integrity: every
customer_idexists in customers. - Freshness: newest row is less than N hours old.
- Volume: row count within a normal range of yesterday's.
- Ranges: amount ≥ 0.
SELECT order_id, COUNT(*) FROM orders GROUP BY 1 HAVING COUNT(*) > 1;
Tools: dbt tests, Great Expectations, custom SQL checks in Airflow.
Example
A nightly load usually brings ~50,000 orders. Tonight: 3,000. The volume check fails, the pipeline stops before the marts refresh, and the team is alerted, instead of the CEO seeing a 94% sales drop at 9 AM.
Traps
- Testing only at the end: catch problems at the raw and staging layers.
- Too many noisy alerts get ignored; tune thresholds.
- A passing test suite isn't proof of correctness; reconcile totals with the source sometimes.
Want the full lesson with step-by-step examples, a project and a certificate? Data Warehousing course, ₹120 →
Questions
5 free questions- Question 1easy
Which check confirms
order_idhas no duplicates? - Question 2medium
The sales dashboard shows ₹0 for today, but the shop was busy. Which check would have caught this?
- Question 3medium
Some sales vanish when joined to dim_customer with an inner join. Which test detects the cause?
- Question 4medium
A uniqueness test on fact_sales fails after a load. What should the pipeline do?
- Question 5easy
A data test is written as a query. What result means the test passes?
Data quality and testing
Data quality and testing
Data quality and testing
Data quality and testing
Data quality and testing
8 more questions on this topic, with hints, and tests
Sign up free for 21 days of every question and test.