0
0
dbtdata~5 mins

Unit testing dbt models - Cheat Sheet & Quick Revision

Choose your learning style9 modes available
Recall & Review
beginner
What is the main purpose of unit testing in dbt models?
Unit testing in dbt models ensures that each model produces the correct output by testing small parts of the data transformation logic independently.
Click to reveal answer
beginner
How do you define a test for a dbt model?
You define a test by writing SQL queries that check for expected conditions, such as no null values or unique keys, and then include these tests in your dbt project.
Click to reveal answer
beginner
What is a common built-in test type in dbt for checking uniqueness?
The built-in test type 'unique' checks that all values in a column are unique, helping to catch duplicate records.
Click to reveal answer
intermediate
Why is it important to run dbt tests regularly during development?
Running dbt tests regularly helps catch errors early, ensures data quality, and prevents broken models from affecting downstream analysis.
Click to reveal answer
intermediate
What is the difference between schema tests and data tests in dbt?
Schema tests check data properties like uniqueness or null values defined in the schema.yml file, while data tests are custom SQL queries that validate specific business logic or data conditions.
Click to reveal answer
Which dbt test checks that a column has no null values?
Arelationships
Bunique
Caccepted_values
Dnot_null
Where do you typically define schema tests in a dbt project?
AIn the model SQL file
BIn the dbt_project.yml file
CIn the schema.yml file
DIn the profiles.yml file
What command runs all tests in a dbt project?
Adbt run
Bdbt test
Cdbt compile
Ddbt seed
Which type of test would you write to check a complex business rule in dbt?
AData test
BSchema test
CUnique test
DNot null test
What happens if a dbt test fails?
AThe test result is logged and the failure is reported
BThe dbt project automatically fixes the error
CThe model is deleted
DNothing, tests do not affect the project
Explain how you would create and run a unit test for a dbt model to check for duplicate values in a column.
Think about using built-in tests and the dbt test command.
You got /4 concepts.
    Describe the difference between schema tests and data tests in dbt and give an example of when to use each.
    Consider the scope and complexity of the test.
    You got /4 concepts.