0
0
dbtdata~10 mins

Building a DAG of models in dbt - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to define a dbt model that selects all columns from the source table.

dbt
select * from [1]
Drag options to blanks, or click blank then click option'
Adbt_source
Bref('source_table')
Cmy_table
Dsource('my_source', 'my_table')
Attempts:
3 left
💡 Hint
Common Mistakes
Using ref() instead of source() for source tables.
Using plain table names without dbt functions.
2fill in blank
medium

Complete the code to create a model that depends on another model called 'customers'.

dbt
select * from [1]
Drag options to blanks, or click blank then click option'
A'customers'
Bref('customers')
Csource('raw', 'customers')
Ddbt.ref('customers')
Attempts:
3 left
💡 Hint
Common Mistakes
Using source() instead of ref() for models.
Using string literals without ref().
3fill in blank
hard

Fix the error in the model code to correctly reference the 'orders' model.

dbt
select * from [1]
Drag options to blanks, or click blank then click option'
Aref('orders')
B'orders'
Cref('order')
Dsource('orders')
Attempts:
3 left
💡 Hint
Common Mistakes
Misspelling the model name as 'order'.
Using source() instead of ref() for models.
4fill in blank
hard

Fill both blanks to create a model that selects customer names and filters orders with amount greater than 100.

dbt
select customer_name, order_amount from [1] where order_amount [2] 100
Drag options to blanks, or click blank then click option'
Aref('orders')
B>
C<
Dsource('sales', 'orders')
Attempts:
3 left
💡 Hint
Common Mistakes
Using source() instead of ref() for models.
Using the wrong comparison operator.
5fill in blank
hard

Fill all three blanks to create a dictionary comprehension that maps model names to their SQL code if the model name starts with 'stg_'.

dbt
model_sql = { [1]: [2] for [3] in models if [3].startswith('stg_') }
Drag options to blanks, or click blank then click option'
Amodel.name
Bmodel.sql
Cmodel
Dmodel_name
Attempts:
3 left
💡 Hint
Common Mistakes
Using a string variable instead of the model object in the loop.
Mixing variable names inconsistently.