Challenge - 5 Problems
Generic Test Mastery
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ Predict Output
intermediate2:00remaining
Output of a generic test with a parameter
Given the following dbt generic test configuration, what will be the output when the test runs on a table with 3 null values in the
email column?dbt
version: 2 models: - name: users columns: - name: email tests: - not_null: severity: warn where: "email LIKE '%@example.com'"
Attempts:
2 left
💡 Hint
Think about how the where clause filters rows before checking for nulls.
✗ Incorrect
The generic test 'not_null' checks for nulls only in rows matching the where clause. Since 3 null emails match the filter, the test fails with 3 nulls found.
🧠 Conceptual
intermediate1:30remaining
Purpose of parameters in dbt generic tests
What is the main purpose of using parameters in dbt generic tests?
Attempts:
2 left
💡 Hint
Parameters help change how tests work without changing the test code itself.
✗ Incorrect
Parameters allow users to adjust test logic, such as filtering rows or setting limits, making tests reusable and flexible.
🔧 Debug
advanced2:00remaining
Identify the error in this generic test with parameters
This dbt generic test is intended to check uniqueness on the
user_id column but raises an error. What is the cause?dbt
version: 2 models: - name: users columns: - name: user_id tests: - unique: where: "user_id != ''" threshold: 0
Attempts:
2 left
💡 Hint
Check which parameters are supported by the 'unique' generic test.
✗ Incorrect
The 'unique' test does not support a 'threshold' parameter, so including it causes an error during compilation or runtime.
❓ data_output
advanced2:00remaining
Result of a generic test with a threshold parameter
A generic test is configured to check that the number of nulls in the
phone column is below a threshold of 2. The table has 3 null values in phone. What is the test result?dbt
version: 2 models: - name: customers columns: - name: phone tests: - not_null: threshold: 2
Attempts:
2 left
💡 Hint
Threshold sets the maximum allowed nulls before failing.
✗ Incorrect
The test fails because the number of nulls (3) is greater than the allowed threshold (2).
🚀 Application
expert3:00remaining
Using multiple parameters in a generic test
You want to create a generic test that checks for duplicates in the
order_id column but only for orders placed in 2023 and allow up to 5 duplicates before failing. Which configuration is correct?Attempts:
2 left
💡 Hint
Combine filtering with threshold to allow some duplicates.
✗ Incorrect
Option D correctly uses 'where' to filter 2023 orders and 'threshold' to allow up to 5 duplicates before failing.