0
0
dbtdata~10 mins

is_incremental() macro 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 check if the model is running incrementally.

dbt
SELECT * FROM {{ source('my_schema', 'my_table') }} WHERE [1]
Drag options to blanks, or click blank then click option'
Ais_full_refresh()
Bis_incremental()
Cis_snapshot()
Dis_table()
Attempts:
3 left
💡 Hint
Common Mistakes
Using is_full_refresh() instead, which checks for full refresh runs.
Confusing is_snapshot() with incremental runs.
2fill in blank
medium

Complete the code to add a filter only when running incrementally.

dbt
SELECT * FROM {{ ref('my_model') }} WHERE [1] AND updated_at > (SELECT MAX(updated_at) FROM {{ this }})
Drag options to blanks, or click blank then click option'
Ais_full_refresh()
Bis_snapshot()
Cis_table()
Dis_incremental()
Attempts:
3 left
💡 Hint
Common Mistakes
Using is_full_refresh() which is true during full refreshes, not incremental runs.
3fill in blank
hard

Fix the error in the code to correctly check for incremental runs.

dbt
{% if [1] %} SELECT * FROM source_table {% else %} SELECT * FROM full_table {% endif %}
Drag options to blanks, or click blank then click option'
Ais_incremental()
Bis_incremental
Dis_incremental()()
Attempts:
3 left
💡 Hint
Common Mistakes
Forgetting parentheses after the macro name.
Adding extra parentheses causing syntax errors.
4fill in blank
hard

Fill both blanks to add a condition that runs only during incremental loads and filters new records.

dbt
SELECT * FROM {{ ref('orders') }} WHERE {% if [1] %} order_date > (SELECT MAX(order_date) FROM [2]) {% else %} TRUE {% endif %}
Drag options to blanks, or click blank then click option'
Ais_incremental()
Bis_full_refresh()
Corders
Dref('orders')
Attempts:
3 left
💡 Hint
Common Mistakes
Using is_full_refresh() instead of is_incremental().
Using plain table name instead of ref() macro.
5fill in blank
hard

Fill all three blanks to create an incremental model that inserts only new records based on id and updated_at.

dbt
WITH new_data AS ( SELECT * FROM {{ ref('source_data') }} ), filtered_data AS ( SELECT * FROM new_data WHERE {% if [1] %} updated_at > ( SELECT MAX(updated_at) FROM [2] ) {% else %} TRUE {% endif %} ) SELECT * FROM [3]
Drag options to blanks, or click blank then click option'
Ais_incremental()
Bthis
Cfiltered_data
Dref('source_data')
Attempts:
3 left
💡 Hint
Common Mistakes
Using ref('source_data') instead of this for existing data.
Selecting from new_data instead of filtered_data.