Cert EspressoLearn. Practise. Find your flow.

A LITTLE FOCUS.
A BIG NEXT STEP.

Your pace. Your space.
dbt Labs · dbt Analytics Engineering

Incremental Models and Strategies

dbt Analytics Engineering · Lesson 7 of 17 · 47:53

YouTube loads only after you press play. This chapter opens at its timestamp in the full course. Watch on YouTube ↗

Learning with these videos? Subscribe for new courses and exam-style questions.

In this lesson

Prepare for the dbt Analytics Engineering Certification exam. In this lesson: how incremental models work with is_incremental and this, unique keys and on_schema_change, and the append, merge, delete+insert, and insert_overwrite strategies, with how to choose one. Includes three original practice questions, with Orchardline Meal Kits, a fictional meal-kit company, as the example.

Study notes

The text of this lesson, to read at your own pace. Information as of November 2026.

An hour to rebuild what did not change

Orchardline's delivery events table grows by millions of rows every week, and rebuilding the events mart as a table now takes almost an hour every night. Most of those rows have not changed since the last run. This lesson covers incremental models, the is incremental macro, unique keys and schema changes, and how to choose an incremental strategy.

How incremental models work

An incremental model is built as a table. On its first run, dbt transforms all the source rows, and on later runs, only the rows you tell it to, usually those created or updated since the last run. The is incremental macro returns true only when the table already exists, the model is materialized as incremental, and the full refresh flag is not passed. So you wrap the filter in an if block on is incremental, and compare a timestamp with the latest value already in the table, which the this variable points to. And the model must be valid SQL whether the macro returns true or false, since the first run and every full refresh skip the filter.

Unique keys and schema changes

Without a unique key, most adapters simply append the selected rows, even when they duplicate existing ones. A unique key, one column or a list of columns, defines the grain of the model, so that a new version of an existing row replaces it, instead of adding a duplicate. Its columns must never contain nulls, or dbt may fail to match rows, and create duplicates. When the model's columns change, on schema change decides what happens: ignore, the default, leaves the table as it is, fail stops with an error, append new columns adds them without removing any, and sync all columns adds new ones and removes missing ones. A full refresh is the other way to apply a big change, by rebuilding the table from scratch.

Append, merge, and delete plus insert

The incremental strategy decides how new rows meet the existing table, and the right one depends on the data volume, on how reliable the unique key is, and on what the platform supports. Append adds the selected rows without checking anything: it is simple and cheap, but it can create duplicates, so it fits immutable data like event logs. Merge adds rows whose unique key is new, and overwrites rows whose key exists, like a type one slowly changing dimension, and without a unique key, it behaves like append. But merge scans the whole destination table, so it can get expensive on large tables. Delete plus insert deletes the target rows that match the new keys, then inserts the new rows, which helps when the unique key is not truly unique, or when merge is not supported.

Insert overwrite, and choosing a strategy

Insert overwrite replaces whole partitions, only the affected ones, which suits large tables partitioned by date, where recent or corrected data must be refreshed without a full rebuild. Microbatch, the newest strategy, splits large time series into time based batches, and lesson eight covers it. To choose, ask three questions: is the data immutable, does a reliable unique key exist, and how large is the destination table? Immutable events point to append, a reliable key on a moderate table points to merge, and partitioned tables with late corrections point to insert overwrite. And merge can be tuned with merge update columns, which updates only the listed columns, while incremental predicates limit how much of the existing table is scanned.

Recap

Let's recap. An incremental model is a table that only transforms new or changed rows after its first run. The is incremental macro returns false on the first run and with full refresh, so the model must work both ways. A unique key, without nulls, prevents duplicates, and on schema change handles new or missing columns. Append is cheap for immutable data, merge overwrites by key but scans the whole table, and delete plus insert replaces matching rows. And insert overwrite replaces whole partitions, for large partitioned tables.

Quick checks for this lesson

The 3 questions of this lesson, as plain text. The button above runs them with shuffled choices and the reason behind every choice.

  1. A developer runs the delivery events model with --full-refresh. What does is_incremental() return during that run, and what does dbt build?

    • False: dbt rebuilds the table from all source rows
    • True: dbt adds only the new rows to the table
    • False: dbt skips the model during this run
    • True: but the filter falls back to yesterday
    Show the answer

    False: dbt rebuilds the table from all source rows

    With the full refresh flag, the macro returns false, the filter is skipped, and dbt rebuilds the table from every source row. “True: dbt adds only the new rows to the table” is wrong, since full refresh is exactly a condition that makes the macro return false. “False: dbt skips the model during this run” is wrong, since dbt still builds the model, from scratch. And “True: but the filter falls back to yesterday” is wrong, since the filter is skipped entirely when the macro returns false.

  2. A new column appears in the events model, while an old column was removed from its SQL. The team wants the new column added, and the old one kept with its history. Which setting fits?

    • on_schema_change: ignore
    • on_schema_change: fail
    • on_schema_change: append_new_columns
    • on_schema_change: sync_all_columns
    Show the answer

    on_schema_change: append_new_columns

    Append new columns adds the new column, and never removes existing ones. “on_schema_change: ignore” is wrong, since ignore, the default, leaves the new column out of the table. “on_schema_change: fail” is wrong, since fail stops the run with an error. And “on_schema_change: sync_all_columns” is wrong, since sync all columns would also drop the old column, which is now missing from the SQL.

  3. The daily revenue table is partitioned by date. Every night, corrections can arrive for any of the last three days. The table is far too large to rebuild. Which strategy fits?

    • append
    • insert_overwrite
    • merge, without a unique_key
    • A table, rebuilt every night
    Show the answer

    insert_overwrite

    Insert overwrite replaces only the affected date partitions, so the three corrected days are rewritten in full. “append” is wrong, since append would add the corrected rows next to the old ones, and duplicate them. “merge, without a unique_key” is wrong, since merge without a unique key behaves like append. And “A table, rebuilt every night” is wrong, since the table is too large to rebuild every night.