dbt · Incremental Models & Performance

What is is_incremental()?

Mediumis_incrementaljinjaincremental

Interview question

What does is_incremental() do in dbt?

How to answer

The short answer

is_incremental() is a Jinja helper that returns true when dbt is running an 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:

SQL
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

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 SQL and delta SQL inside one model file."