Building Incremental Models (is_incremental(), Merge Strategies, Lookback Windows)
Ship incremental models with merge strategies and lookback windows that tolerate late data.
In plain words
Full relation and recorded upper watermark. Next, inclusive cursor plus lateness lookback. Finally, rerun and compare with bounded full refresh.
Think of it like…
An incremental ledger leaves the last pages open for corrections; the lookback is the number of pages it rechecks so a delayed eraser does not escape the update.
Where you’ve seen it
WHERE updated_at >= (SELECT max(updated_at) - interval '3 days' FROM {{ this }}) plus unique_key=['tenant_id','event_id'] and delete/change capture reconciles a 72-hour correction window.
Words you’ll hear
- is_incremental
- A Jinja condition that is true only when a valid target relation exists and the invocation is not a full refresh.
- Merge
- A warehouse-specific append, merge, delete+insert, insert-overwrite, or micro-batch method for applying deltas.
- Lookback
- An overlap range longer than observed source lateness that recomputes records which may have arrived after the first load.
- Operational boundary
- Filtering only by
>of the target maximum timestamp misses same-timestamp rows, deletes and corrections never arrive, and replaying a failed micro-batch outside the transactional strategy duplicates output. Choose an inclusive stable cursor with unique-key tie breakers, overlap by measured lateness, MERGE deterministic business identities, handle hard deletes explicitly, and prove full-refresh parity with an idempotent rerun test.
Visual diagram
Theory & deep dive
is_incremental: the working mechanism
A dbt incremental model executes a first full build and later limits source input under is_incremental(), then appends or MERGEs by unique key while a lookback window captures delayed source updates.
Full relation and recorded upper watermark. Inclusive cursor plus lateness lookback, then append/merge/delete strategy by durable key; this exposes the state governed by Lookback.
WHERE updated_at >= (SELECT max(updated_at) - interval '3 days' FROM {{ this }}) plus unique_key=['tenant_id','event_id'] and delete/change capture reconciles a 72-hour correction window.
is_incremental(), then appends or MERGEs by unique key while a lookback window captures delayed source updatesBuilding Incremental Models , Merge Strategies, Lookback Windows): failure mode and production response
Filtering only by > of the target maximum timestamp misses same-timestamp rows, deletes and corrections never arrive, and replaying a failed micro-batch outside the transactional strategy duplicates output.
Choose an inclusive stable cursor with unique-key tie breakers, overlap by measured lateness, MERGE deterministic business identities, handle hard deletes explicitly, and prove full-refresh parity with an idempotent rerun test. Track Lookback as "based on p99 late-arrival delay plus margin", and make Cursor tie visible to the dataset owner.
How it works, step by step
Step 1 of 41. Bootstrap
Full relation and recorded upper watermark. A dbt incremental model executes a first full build and later limits source input under is_incremental(), then appends or MERGEs by unique key while a lookback window captures delayed source updates.
- Lookback
- based on p99 late-arrival delay plus margin
- Merge
- A warehouse-specific append, merge, delete+insert, insert-overwrite, or micro-batch method for applying deltas.
When to use it & trade-offs
What it is
A dbt incremental model executes a first full build and later limits source input under is_incremental(), then appends or MERGEs by unique key while a lookback window captures delayed source updates. WHERE updated_at >= (SELECT max(updated_at) - interval '3 days' FROM {{ this }}) plus unique_key=['tenant_id','event_id'] and delete/change capture reconciles a 72-hour correction window.
Why it matters: Filtering only by > of the target maximum timestamp misses same-timestamp rows, deletes and corrections never arrive, and replaying a failed micro-batch outside the transactional strategy duplicates output. Choose an inclusive stable cursor with unique-key tie breakers, overlap by measured lateness, MERGE deterministic business identities, handle hard deletes explicitly, and prove full-refresh parity with an idempotent rerun test.
When to reach for it
- Ship incremental models with merge strategies and lookback windows that tolerate late data.
- Choose is_incremental because it provides this capability: A Jinja condition that is true only when a valid target relation exists and the invocation is not a full refresh.
- Keep evidence for Lookback at "based on p99 late-arrival delay plus margin" so the last production stage-Reconcile - rerun and compare with bounded full refresh-remains testable.
When to avoid or be careful
- Filtering only by
>of the target maximum timestamp misses same-timestamp rows, deletes and corrections never arrive, and replaying a failed micro-batch outside the transactional strategy duplicates output. - Do not conflate Merge with is_incremental. The second concept contributes different behavior: A warehouse-specific append, merge, delete+insert, insert-overwrite, or micro-batch method for applying deltas.
- Release only after this guardrail is in place: Choose an inclusive stable cursor with unique-key tie breakers, overlap by measured lateness, MERGE deterministic business identities, handle hard deletes explicitly, and prove full-refresh parity with an idempotent rerun test.
is_incremental / Merge / Lookback - roles, limits, and operating cost
Strengths: A Jinja condition that is true only when a valid target relation exists and the invocation is not a full refresh. A dbt incremental model executes a first full build and later limits source input under is_incremental(), then appends or MERGEs by unique key while a lookback window captures delayed source updates.
Watch out: Filtering only by > of the target maximum timestamp misses same-timestamp rows, deletes and corrections never arrive, and replaying a failed micro-batch outside the transactional strategy duplicates output.
Strengths: A warehouse-specific append, merge, delete+insert, insert-overwrite, or micro-batch method for applying deltas. In this workflow it supports: Apply - append/merge/delete strategy by durable key.
Watch out: The operating cost is real: timestamp plus stable sequence/key for exact batching.
Strengths: An overlap range longer than observed source lateness that recomputes records which may have arrived after the first load. Its output can be checked with Full-refresh parity.
Watch out: Operating guardrail: Choose an inclusive stable cursor with unique-key tie breakers, overlap by measured lateness, MERGE deterministic business identities, handle hard deletes explicitly, and prove full-refresh parity with an idempotent rerun test.
Interview signals & numbers to know
When this topic comes up
- “Where is the failure boundary for is_incremental, and how would Lookback reveal it?”
- “Why is Merge distinct from this behavior: an overlap range longer than observed source lateness that recomputes records which may have arrived after the first load?”
- Production clue: Filtering only by > of the target maximum timestamp misses same-timestamp rows, deletes and corrections never arrive, and replaying a failed micro-batch outside the transactional strategy duplicates output.
- Design probe: Choose an inclusive stable cursor with unique-key tie breakers, overlap by measured lateness, MERGE deterministic business identities, handle hard deletes explicitly, and prove full-refresh parity with an idempotent rerun test.
Benchmarks & rules of thumb
- Lookback
- based on p99 late-arrival delay plus margin
- Cursor tie
- timestamp plus stable sequence/key for exact batching
- Full-refresh parity
- incremental result hashes equal recomputation for test windows
Common mistakes & follow-ups
Common interview mistakes
- Filtering only by
>of the target maximum timestamp misses same-timestamp rows, deletes and corrections never arrive, and replaying a failed micro-batch outside the transactional strategy duplicates output. - Reporting success from a job exit code without checking Lookback and Cursor tie.
- Treating this example as complete without replay, rollback, or access boundaries:
WHERE updated_at >= (SELECT max(updated_at) - interval '3 days' FROM {{ this }})plusunique_key=['tenant_id','event_id']and delete/change capture reconciles a 72-hour correction window.
Likely interviewer follow-ups
- How would you prove this contract instead of only checking that the command ran: A Jinja condition that is true only when a valid target relation exists and the invocation is not a full refresh.
- What does the recovery plan do when this occurs? Filtering only by
>of the target maximum timestamp misses same-timestamp rows, deletes and corrections never arrive, and replaying a failed micro-batch outside the transactional strategy duplicates output. - When is is_incremental insufficient for Cursor tie, and what does adding Merge cost in Lookback?
is_incremental(), then appends or MERGEs by unique key while a lookback window captures delayed source updates. Then make the answer operational: Choose an inclusive stable cursor with unique-key tie breakers, overlap by measured lateness, MERGE deterministic business identities, handle hard deletes explicitly, and prove full-refresh parity with an idempotent rerun test.Knowledge check
Put it into practice
Practice related interview Q&A
Apply Building Incremental Models (is_incremental(), Merge Strategies, Lookback Windows) with data engineer interview Q&A and hands-on practice.