dbt Fundamentals
Back to Building a Real dbt Project

Incremental Models in Detail

The most-used and most-misused materialization. Patterns that work, gotchas that bite. FIND_VIDEO: search 'dbt incremental model unique_key' — recommended channel: dbt Labs. Aim for 11 min or under.

11 minutesVideo LessonPDF notes
🎯 Free Guest Mode: You are learning for free. Sign in to save your completion progress and quiz answers.
Loading progress...

Key moments

  1. Incremental Concepts and Syntax — Covers cost and runtime benefits alongside the incremental materialization config and is_incremental macro.
  2. Implementing Incremental Filters — Demonstrates writing the WHERE clause using the max value from the target relation reference.
  3. Executing the Initial Run — Explains why the first execution defaults to a full table create statement.
  4. Testing Subsequent Runs — Shows how inserting new source records triggers an append-only insert on existing tables.
  5. Handling Updates with Unique Keys — Illustrates how defining unique_key switches dbt from duplicate inserts to table merge operations.
  6. Schema Evolution Configuration — Walks through configuring on_schema_change settings to handle new columns without failing runs.
PDF notes

Frequently asked questions

Why did my incremental model rebuild the entire table instead of inserting new rows?

The target table did not exist yet, or the run was executed with the `--full-refresh` flag. In both cases, `is_incremental()` evaluates to false.

What happens if source rows are updated but no unique_key is configured?

dbt will perform an append-only `INSERT`, resulting in duplicate records containing both the old and updated versions of the same entity.

Does on_schema_change='append_new_columns' populate values for older rows?

No, it alters the table schema, leaving previous rows with `NULL` values until you perform a full refresh.

How was this lesson?

Your feedback helps us refine explanations and catch bugs.