DT2: Data quality you can prove

Lesson 3 of 5 · reading 15–25 minutes; practice and project time is on the module page

Validation rules and quarantine

🎯You'll be able to

Turn expectations into validation rules, apply them to each row, and keep rows that fail in a quarantine table with a reason.

🏠The everyday picture

At an airport, bags that fail the scan aren't thrown away or let through: they go to a separate belt, with a note saying why, and someone checks them.

📘What it really is

source_file row_number reason raw_row
orders/2026-10-05.csv 118 qty must be a positive whole number {"order_id": "SS-100562", "qty": "-1", ...}

📝A worked example

Input: the solution's loader on 5 October (python -m pipeline.run --date 2026-10-05), then select reason, count(*) from clean.quarantine group by reason.

Expected output: 2 rows with "qty must be a positive whole number" and 1 with "unknown sku". Across all 30 days: 60 and 30. Nothing else fails, because the date, amount and status rules from DT1 read every other value.

🌍Where it's used

📝Case scenario

An insurer's claims pipeline dropped rows that failed checks. A hospital's claims had a new date format and vanished for a month; the hospital called to ask why nothing was paid. With a quarantine table, the first day's 400 quarantined claims would have shown up on the morning report.

🖱️Try it

In the starter's pipeline/run.py, find every place a row is dropped without being counted. Success: you can point to the line that drops rows silently and say what the solution does instead.

⚠️Common mistakes

🛠️For your project

Project 1 test 6 checks that 90 rows are quarantined, each with a reason, across the month.

✅Quick check

What three things can a rule do with a failing row?

Show the answer

Quarantine it, leave it out on purpose and count it, or stop the load.

What goes in a quarantine row?

Show the answer

The file, the row number, the reason and the original values.

← PreviousProfiling a new dataset
ProLearners Assist