0
0
dbtdata~20 mins

Testing model outputs in dbt - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Master of Testing Model Outputs
Get all challenges correct to earn this badge!
Test your skills under time pressure!
Predict Output
intermediate
2:00remaining
Output of a simple aggregation test in dbt
Given a dbt model that calculates total sales per region, what will be the output of this test query?
dbt
select region, sum(sales) as total_sales from sales_data group by region order by region;
A[{"region": "East", "total_sales": 1500}, {"region": "West", "total_sales": 2000}]
B[{"region": "East", "total_sales": 3500}, {"region": "West", "total_sales": 3500}]
C[{"region": "East", "total_sales": 2000}, {"region": "West", "total_sales": 1500}]
D[{"region": "East", "total_sales": null}, {"region": "West", "total_sales": 2000}]
Attempts:
2 left
💡 Hint
Sum sales grouped by region and order by region alphabetically.
data_output
intermediate
1:30remaining
Result of a null value test in a dbt model
What will be the output of this test that checks for null values in the 'customer_id' column?
dbt
select count(*) as null_count from customers where customer_id is null;
A[{"null_count": 0}]
B[{"null_count": 5}]
C[{"null_count": null}]
DSyntaxError
Attempts:
2 left
💡 Hint
Count rows where customer_id is null.
🔧 Debug
advanced
2:00remaining
Identify the error in this dbt test SQL
What error will this dbt test SQL raise when run?
dbt
select customer_id, count(*) from orders group by customer_id having count(*) >;
ANo error, returns rows
BTypeError
CSyntaxError
DRuntimeError
Attempts:
2 left
💡 Hint
Check the HAVING clause syntax.
🚀 Application
advanced
2:30remaining
Interpreting test results for data freshness in dbt
A dbt test checks if the 'last_updated' timestamp in a model is within the last 24 hours. The test returns 3 rows. What does this mean?
AThe test failed due to syntax error
B3 rows have last_updated within the last 24 hours, data is fresh
C3 rows have null last_updated values
D3 rows have last_updated older than 24 hours, indicating stale data
Attempts:
2 left
💡 Hint
Tests usually return rows that fail the condition.
🧠 Conceptual
expert
2:00remaining
Understanding the impact of test failures on dbt runs
If a dbt test on a model fails during a run, what is the default behavior of dbt regarding the run status?
AThe dbt run fails and stops execution immediately
BThe dbt run completes successfully but marks the test as failed
CThe dbt run ignores test failures and continues silently
DThe dbt run retries the test automatically until it passes
Attempts:
2 left
💡 Hint
Tests are separate from model builds in dbt.