Challenge - 5 Problems
Incremental Model Mastery
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ Predict Output
intermediate2:00remaining
Output of is_incremental() in a full-refresh run
Consider a dbt model using the
is_incremental() macro. What will be the output of the following code snippet during a full-refresh run?select case when {{ is_incremental() }} then 'Incremental' else 'Full Refresh' end as run_typedbt
select case when {{ is_incremental() }} then 'Incremental' else 'Full Refresh' end as run_typeAttempts:
2 left
💡 Hint
Think about what
is_incremental() returns when the model is run with a full-refresh flag.✗ Incorrect
The
is_incremental() macro returns true only when the model is run incrementally. During a full-refresh run, it returns false, so the output is 'Full Refresh'.❓ data_output
intermediate2:00remaining
Rows processed in incremental vs full-refresh runs
A dbt incremental model uses
What is the expected number of rows processed during a full-refresh run compared to an incremental run?
is_incremental() to insert only new rows:select * from source_table where updated_at > (select max(updated_at) from {{ this }})What is the expected number of rows processed during a full-refresh run compared to an incremental run?
dbt
select * from source_table where updated_at > (select max(updated_at) from {{ this }})
Attempts:
2 left
💡 Hint
Consider what data is available in the target table during each run type.
✗ Incorrect
During a full-refresh, the target table is empty or replaced, so all rows are processed. During incremental runs, only rows with updated timestamps greater than the max in the target table are processed.
🔧 Debug
advanced2:00remaining
Why does this incremental model fail on full-refresh?
This dbt model uses
When run with full-refresh, it fails with a syntax error. Why?
is_incremental() to insert new data:select * from source_table where {{ 'true' if is_incremental() else 'false' }}When run with full-refresh, it fails with a syntax error. Why?
dbt
select * from source_table where {{ 'true' if is_incremental() else 'false' }}
Attempts:
2 left
💡 Hint
Check what the SQL looks like after macro expansion during full-refresh.
✗ Incorrect
The else clause outputs the string 'false' directly in the WHERE clause, which is invalid SQL syntax. It should output a valid condition like '1=1' or 'true'.
🚀 Application
advanced3:00remaining
Using is_incremental() to update only changed rows
You want to write a dbt incremental model that updates only rows changed since the last run. Which SQL snippet correctly uses
Options:
is_incremental() to achieve this?Options:
Attempts:
2 left
💡 Hint
Think about how to conditionally run different queries based on incremental or full-refresh mode.
✗ Incorrect
Option B correctly uses a Jinja if-else to run a filtered query during incremental runs and full data during full-refresh. Other options misuse the macro in SQL conditions.
🧠 Conceptual
expert2:00remaining
Understanding is_incremental() behavior in dbt runs
Which statement best describes the behavior of the
is_incremental() macro in dbt models?Attempts:
2 left
💡 Hint
Recall the purpose of incremental models and how dbt distinguishes run types.
✗ Incorrect
is_incremental() is designed to detect incremental runs only. It returns true during incremental runs and false during full-refresh or initial runs.