0
0
dbtdata~20 mins

Running tests with dbt test - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
dbt Test Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
Predict Output
intermediate
2:00remaining
Output of a dbt test run with a failing test
What is the output shown when you run dbt test and one of the tests fails due to a uniqueness violation?
dbt
dbt test
ANo tests found to run in the project.
BTest failed: uniqueness test on column 'user_id' in model 'orders' failed with 3 duplicate rows found.
CSyntaxError: invalid syntax in dbt test command.
DAll tests passed successfully with no errors.
Attempts:
2 left
💡 Hint
Think about what dbt reports when a uniqueness test fails.
🧠 Conceptual
intermediate
1:30remaining
Purpose of dbt test command
What is the main purpose of running dbt test in a dbt project?
ATo run data quality checks defined as tests on models and sources.
BTo generate documentation for the dbt project.
CTo deploy the dbt project to production environment.
DTo compile SQL models into tables and views.
Attempts:
2 left
💡 Hint
Think about what tests in dbt are used for.
data_output
advanced
2:00remaining
Result of a custom test returning rows
You define a custom test in dbt that returns rows where order_amount is negative. What does dbt test output if 5 rows violate this condition?
dbt
select * from {{ ref('orders') }} where order_amount < 0
ATest passed: no rows returned.
BRuntime error: invalid SQL syntax.
CTest skipped: no test defined.
DTest failed: 5 rows returned violating the condition.
Attempts:
2 left
💡 Hint
Custom tests fail when they return any rows.
🔧 Debug
advanced
2:00remaining
Error when running dbt test with missing test file
You run dbt test but get an error: Compilation Error: Could not find test file 'not_null_user_id.sql'. What is the cause?
AThe model 'user_id' does not exist in the project.
BThe database connection is not configured properly.
CThe test file is missing or not placed in the correct tests directory.
DThe dbt version is outdated and does not support tests.
Attempts:
2 left
💡 Hint
Check where dbt expects test files to be located.
🚀 Application
expert
3:00remaining
Interpreting dbt test summary output
After running dbt test, you see this summary:

PASS 1/3 tests
FAIL 2/3 tests
- test_not_null on model customers
- test_unique on model orders


What should you do next?
AInvestigate the failing tests to understand data quality issues and fix them.
BIgnore the failures since one test passed.
CDelete the failing tests to avoid errors in future runs.
DRun <code>dbt run</code> to overwrite the data and fix tests automatically.
Attempts:
2 left
💡 Hint
Failing tests indicate data problems that need attention.