Skip to content
LakeBench
ProblemsCommunityPricing
Sign inStart practicing
Back
  1. Home
  2. Interview prep
  3. What is is_incremental()?

dbt · Incremental Models & Performance

What is is_incremental()?

Mediumdbt-20
is_incrementaljinjaincremental

Question

What does is_incremental() do in dbt?

Solution

is_incremental() is a Jinja helper that returns true when dbt is running an incremental model in incremental mode (the target table already exists and you are not doing a full refresh).

Typical use

Wrap filters so the first build loads history, and later builds only load new data:

select * from {{ ref('stg_events') }}
{% if is_incremental() %}
where event_time > (select max(event_time) from {{ this }})
{% endif %}

When it is false

  • First run (relation does not exist yet)
  • dbt run --full-refresh
  • Non-incremental materializations (the block simply should not appear, or still evaluates false)

Mental model

is_incremental() == false  →  process full SELECT (history)
is_incremental() == true   →  process filtered SELECT (delta)

Common mistake

Putting the filter outside of is_incremental() so the first run also filters against an empty/missing {{ this }} and loads nothing.

Interview tip: "is_incremental() switches between backfill SQL and delta SQL inside one model file."

PreviousNext