Quality and Contracts for Analytics Engineers
Quality and contracts in dbt cover how you prove models are correct and keep their shape stable. Tests check uniqueness, non-null values, accepted values and relationships, while model contracts and versions fix column names and types so downstream users are not broken by changes.
Stage: dbt in Depth · Part of the Analytics Engineer roadmap · Last reviewed 19 November 2026
What to learn in Quality and Contracts
- Add unique and not_null tests to a primary key
- Write a relationships test between a fact and a dimension
- Create a singular test with a custom SQL query
- Enforce a model contract with declared column types
- Release a new model version while keeping the old one
Quality and Contracts interview questions
What are the four built-in generic tests in dbt?
They are unique, not_null, accepted_values and relationships. Together they check key integrity, missing values, allowed categories and foreign key links, and cover a large share of common data issues with a few lines of YAML.
What does a model contract do?
A contract declares the expected columns and data types of a model, and dbt fails the build if the output does not match. It protects downstream consumers from silent breaking changes.
Where Quality and Contracts fits in the Analytics Engineer roadmap
Quality and Contracts belongs to the dbt in Depth stage (intermediate level), which takes about 7 hours. The core craft.
Other units in this stage
Back to the full Analytics Engineer roadmap