Quality
Quality overview: how assertions, DQ checks, and unit tests work together to keep models trustworthy, and when to use each.
Use Assertions, Data Quality checks, and Unit Tests together to keep a model trustworthy.
Three tools, three jobs. Unit tests catch logic bugs in your transformations before they run anywhere. Assertions block bad rows at write time. Data Quality checks watch for trends without blocking the pipeline.
The three-layer quality strategy
When to use each:
The key difference: assertions stop everything if they fail. Data quality checks and tests warn you, so you can investigate without blocking production.
How they work together
Execution order:
Unit Tests run during development to validate logic, catching bugs before deployment.
Plan applies changes to the environment.
Model executes the transformation.
Assertions run immediately and block the run on failure.
Data Quality checks run after a successful run or plan apply to track quality over time, without blocking.
Unit tests run first against fixtures. Assertions run with the model and stop the run on failure. Data Quality checks run after the models build successfully to track quality over time. Each layer catches what the previous one isn't designed to.
Running quality tools
Best practices
Do
Start with assertions. Add critical blocking validations first, before worrying about trends.
Add data quality checks gradually: monitor trends first, then tighten thresholds as you learn what's normal.
Test during development, before deploying.
Use descriptive names, like
revenue_mismatch_with_rawinstead ofcheck_1.Order assertions efficiently: fast checks first, slow checks last.
Don't
Don't use data quality checks for critical rules. If it's critical, it should block: use an assertion.
Don't skip assertion failures. Fix the root cause.
Don't over-audit. Focus on critical business rules.
Don't ignore data quality trends. Consistently failing checks signal a real problem.
Choose a page
Unit Tests - validate model logic with controlled inputs and expected outputs.
Assertions - attach audits to models to block bad data at runtime.
Data Quality - attach expectation-based checks that monitor datasets over time.
Last updated
Was this helpful?