Interview's MateData Engineer
Interview's Mate

Data Engineer

SQL · Spark · Lakehouse · Streaming

Visualizer

DSA Visualizer
All 32 lessons
Custom Playground
Try your own examples

Learning

System Design
31 architecture topics
SQL Learning
160 foundations → production topics
AI Engineering
160 LLM → backend topics
Data Science
160 Python → MLOps topics
Data Engineer
160 SQL → streaming topics
Docker
160 Docker learning topics
Kubernetes
160 K8s fundamentals → cloud
Java LearnSoon
Coming soon
Python Learn
Interview Q&A & internals
JavaScript Learn
Closures, async & DOM Q&A
Tech Learn
Search, practise & track Q&A
AI DSA Practice
Solve coding problems
Theme
Home
Data Engineer topics
Lesson 105/ 160
06. Data Transformation (dbt) & Workflow Orchestration

Building Incremental Models (is_incremental(), Merge Strategies, Lookback Windows)

Ship incremental models with merge strategies and lookback windows that tolerate late data.

Advancedis_incremental · Merge · Lookback3 quiz questions
Practice Generative AI Q&A
In plain wordsDiagramTheoryStep by stepWhen to use itInterview cluesMistakes to avoidQuiz (3)Practice

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

Loading interactive 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.

Building Incremental Models , Merge Strategies, Lookback Windows) in one concrete design

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.

Key takeaway: 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

Building 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.

Key takeaway: 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.

How it works, step by step

Step 1 of 4
is_incremental

1. 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.

full relation and recorded upper watermark
Key numbers at this step
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

is_incremental
Best for: A Jinja condition that is true only when a valid target relation exists and the invocation is not a full refresh.

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.

Merge
Best for: A warehouse-specific append, merge, delete+insert, insert-overwrite, or micro-batch method for applying deltas.

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.

Lookback
Best for: An overlap range longer than observed source lateness that recomputes records which may have arrived after the first load.

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 }}) plus unique_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?
Interview tip: Lead with the data path and failure boundary: 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. 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

Loading quiz

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.

Open Data Engineer Q&A →Machine Learning Q&A
Previous topic
Materializations (view, table, incremental, ephemeral)
Next topic
Jinja Templating, Macros & Custom SQL Generation in dbt