Challenge - 5 Problems
dbt Built-in Tests Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ Predict Output
intermediate2:00remaining
Output of a unique test on a column with duplicates
Given a dbt model with the following data in the
What will be the result of running a
users table:id | name ---|------ 1 | Alice 2 | Bob 2 | Charlie 3 | David
What will be the result of running a
unique test on the id column?dbt
version: 2
models:
- name: users
columns:
- name: id
tests:
- uniqueAttempts:
2 left
💡 Hint
Think about what the
unique test checks for in a column.✗ Incorrect
The
unique test checks if all values in the column are distinct. Since id has duplicate value 2, the test fails.❓ data_output
intermediate2:00remaining
Result of a not_null test on a column with null values
Consider a
What will be the result of running a
products table with this data:product_id | price ----------|------- 101 | 9.99 102 | NULL 103 | 15.00
What will be the result of running a
not_null test on the price column?dbt
version: 2
models:
- name: products
columns:
- name: price
tests:
- not_nullAttempts:
2 left
💡 Hint
Remember what the
not_null test checks for.✗ Incorrect
The
not_null test fails if any value in the column is NULL. Here, price has a NULL value, so the test fails.🧠 Conceptual
advanced1:30remaining
Purpose of accepted_values test in dbt
What is the main purpose of the
accepted_values test in dbt?Attempts:
2 left
💡 Hint
Think about validating categorical or enumerated data.
✗ Incorrect
The
accepted_values test checks if all values in a column are within a specified set of allowed values.❓ Predict Output
advanced2:00remaining
Output of a relationships test with missing foreign key
Given two tables:
What will be the result of running a
orders: order_id | customer_id ---------|------------ 1 | 10 2 | 20 3 | 30 customers: customer_id ----------- 10 20
What will be the result of running a
relationships test on orders.customer_id referencing customers.customer_id?dbt
version: 2 models: - name: orders columns: - name: customer_id tests: - relationships: to: ref('customers') field: customer_id
Attempts:
2 left
💡 Hint
Check if all foreign keys in
orders exist in customers.✗ Incorrect
The
relationships test checks if every foreign key value exists in the referenced table. Since 30 is missing in customers, the test fails.🔧 Debug
expert2:30remaining
Identify the error in this dbt test configuration
Look at this dbt test configuration snippet:
What is the main issue that will cause a test failure or error?
version: 2
models:
- name: sales
columns:
- name: region
tests:
- accepted_values:
values: ["North", "South", "East", "West"]
- relationships:
to: ref('regions')
field: region_idWhat is the main issue that will cause a test failure or error?
Attempts:
2 left
💡 Hint
Check if the columns referenced in tests match the column names defined.
✗ Incorrect
The
relationships test references a different column (region_id) than the one defined (region), causing a mismatch and test failure.