0
0
dbtdata~20 mins

Creating your first model in dbt - Practice Exercises

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
dbt Model Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
Predict Output
intermediate
2:00remaining
What is the output of this dbt model SQL?
Given the following dbt model SQL, what will be the resulting table's row count if the source table has 100 rows with 20 rows having NULL in the column status?
dbt
select * from {{ source('raw_data', 'orders') }} where status is not null
A0 rows
B100 rows
C20 rows
D80 rows
Attempts:
2 left
💡 Hint
Think about how the WHERE clause filters rows with NULL status.
data_output
intermediate
2:00remaining
What columns will the model output have?
Consider this dbt model SQL that selects specific columns from a source table. What columns will the resulting model table contain?
dbt
select order_id, customer_id, order_date from {{ source('raw_data', 'orders') }}
AAll columns from orders table
Border_id, customer_id, order_date
COnly order_id
Dorder_id, customer_id, order_date, status
Attempts:
2 left
💡 Hint
Look at the SELECT statement columns.
🔧 Debug
advanced
2:00remaining
Why does this dbt model fail to compile?
This dbt model SQL throws a compilation error. What is the cause?
dbt
select * from {{ source('raw_data', orders) }}
AMissing quotes around the table name 'orders' in the source function
BMissing schema name in the source function
CUsing * is not allowed in dbt models
DThe source function requires three arguments
Attempts:
2 left
💡 Hint
Check the syntax of the source function arguments.
🚀 Application
advanced
2:30remaining
How to create a model that aggregates total sales per customer?
You want to create a dbt model that shows total sales amount per customer from the orders source table with columns customer_id and amount. Which SQL snippet correctly achieves this?
Aselect customer_id, amount from {{ source('raw_data', 'orders') }} group by customer_id
Bselect customer_id, sum(amount) from {{ source('raw_data', 'orders') }}
Cselect customer_id, sum(amount) as total_sales from {{ source('raw_data', 'orders') }} group by customer_id
Dselect customer_id, total(amount) as total_sales from {{ source('raw_data', 'orders') }} group by customer_id
Attempts:
2 left
💡 Hint
Remember to use GROUP BY when aggregating and alias the sum.
🧠 Conceptual
expert
2:00remaining
What is the main benefit of using dbt models for data transformation?
Choose the best explanation for why dbt models are useful in data projects.
AThey allow version-controlled, modular SQL transformations that build a clear data pipeline
BThey automatically clean data without writing any SQL code
CThey replace the need for any database or data warehouse
DThey provide a graphical interface to drag and drop data transformations
Attempts:
2 left
💡 Hint
Think about how dbt helps organize and manage SQL code.