Jump into concepts and practice - no test required
or
Recommended
Test this pattern10 questions across easy, medium, and hard to know if this pattern is strong
Recall & Review
beginner
What is the main purpose of testing model outputs in dbt?
To ensure that the data produced by your models is accurate, consistent, and meets expected quality standards before using it for analysis or reporting.
Click to reveal answer
beginner
Name two common types of tests used in dbt to validate model outputs.
1. Unique tests - to check if a column has unique values. 2. Not null tests - to ensure no missing values in a column.
Click to reveal answer
intermediate
How does a dbt 'schema test' help in testing model outputs?
Schema tests check the structure and data quality of your model outputs by validating constraints like uniqueness, non-null values, and referential integrity.
Click to reveal answer
intermediate
What is a 'custom test' in dbt and when would you use it?
A custom test is a user-defined SQL query that checks specific conditions in your data. Use it when built-in tests don't cover your unique data quality rules.
Click to reveal answer
beginner
Why is it important to run tests regularly on model outputs in dbt?
Regular testing catches data issues early, prevents bad data from spreading, and maintains trust in your data pipelines and reports.
Click to reveal answer
Which dbt test checks if a column contains no missing values?
AReferential integrity test
BUnique test
CNot null test
DCustom test
✗ Incorrect
The not null test ensures that a column has no missing (null) values.
What does a unique test in dbt verify?
AThat data types are correct
BThat no values are missing
CThat values match another table
DThat all values in a column are different
✗ Incorrect
A unique test checks that all values in a column are distinct with no duplicates.
When should you create a custom test in dbt?
AWhen you want to speed up model runs
BWhen built-in tests do not cover your specific data rules
CWhen you want to change data types
DWhen you want to create new models
✗ Incorrect
Custom tests are used to check data conditions that built-in tests do not support.
What is the benefit of running tests on model outputs before analysis?
ATo ensure data accuracy and reliability
BTo reduce storage space
CTo speed up SQL queries
DTo create visualizations
✗ Incorrect
Testing ensures the data is accurate and reliable for analysis.
Which of the following is NOT a typical dbt test?
AData type test
BUnique test
CNot null test
DReferential integrity test
✗ Incorrect
dbt does not have a built-in data type test; it focuses on uniqueness, nulls, and referential integrity.
Explain how you would use dbt tests to ensure your model outputs are trustworthy.
Think about built-in tests and when to create your own.
You got /5 concepts.
Describe the difference between a schema test and a custom test in dbt.
Consider what each test type validates.
You got /3 concepts.
Practice
(1/5)
1. What is the main purpose of testing model outputs in dbt?
easy
A. To ensure the data is accurate and reliable
B. To speed up the data loading process
C. To create new tables automatically
D. To delete old data from the database
Solution
Step 1: Understand the goal of testing in dbt
Testing checks if the data produced by models is correct and trustworthy.
Step 2: Identify the main benefit of testing outputs
Accurate and reliable data helps users make good decisions and trust reports.
Final Answer:
To ensure the data is accurate and reliable -> Option A
Quick Check:
Testing = Accurate data [OK]
Hint: Testing checks data correctness, not speed or deletion [OK]
Common Mistakes:
Thinking tests speed up loading
Confusing testing with table creation
Assuming tests delete data
2. Which of the following is the correct syntax to define a uniqueness test on a column user_id in a dbt model's schema.yml file?
But when you run dbt test, you get an error saying Invalid test configuration. What is the likely cause?
medium
A. The test name should be unique and not_null without dashes
B. The indentation of the tests list is incorrect
C. The model name should be under models key in schema.yml
D. The email column does not exist in the model
Solution
Step 1: Check the structure of schema.yml
Tests must be defined under the models: key in schema.yml.
Step 2: Identify missing models: key
The snippet misses the models: root key, causing invalid configuration.
Final Answer:
The model name should be under models key in schema.yml -> Option C
Quick Check:
Missing 'models:' key = config error [OK]
Hint: Always start schema.yml tests under 'models:' key [OK]
Common Mistakes:
Removing dashes from test names
Incorrect indentation of tests list
Not placing model under 'models:'
5. You want to test that the status column in your transactions model only contains the values 'pending', 'completed', or 'failed'. Which test definition in schema.yml correctly enforces this?
hard
A. - name: transactions
columns:
- name: status
tests:
- values_in: ['pending', 'completed', 'failed']
B. - name: transactions
columns:
- name: status
tests:
- accepted_values:
values: ['pending', 'completed', 'failed']
C. - name: transactions
columns:
- name: status
tests:
- accepted_values: ['pending', 'completed', 'failed']
D. - name: transactions
columns:
- name: status
tests:
- unique
- not_null
Solution
Step 1: Identify the correct test for allowed values
The accepted_values test checks if column values are in a list.
Step 2: Check correct syntax for accepted_values
The test requires a dictionary with key values listing allowed values.
Final Answer:
- name: transactions
columns:
- name: status
tests:
- accepted_values:
values: ['pending', 'completed', 'failed'] -> Option B
Quick Check:
accepted_values with 'values' key = - name: transactions
columns:
- name: status
tests:
- accepted_values:
values: ['pending', 'completed', 'failed'] [OK]
Hint: Use accepted_values with 'values' list for allowed values [OK]
Common Mistakes:
Using unique or not_null instead of accepted_values