Skip to content
LakeBench
ProblemsCommunityPricing
Sign inStart practicing
Back
  1. Home
  2. Interview prep
  3. on_schema_change

dbt · Incremental Models & Performance

on_schema_change

Harddbt-25
on_schema_changeschema evolutionincremental

Question

What does on_schema_change do on incremental models?

Solution

on_schema_change tells dbt what to do when the compiled SELECT columns differ from the existing incremental table schema.

Common settings

  • ignore (often default): new columns in SQL may not appear in the table; mismatches can error depending on adapter/behavior
  • fail: stop if schemas differ (safe, explicit)
  • append_new_columns: add new columns to the existing table; do not remove old ones
  • sync_all_columns: attempt to add/remove columns to match the model (adapter-specific; use carefully)
{{ config(
    materialized='incremental',
    unique_key='id',
    on_schema_change='append_new_columns'
) }}

Mental model

model SQL gains column "discount"
        |
on_schema_change decides:
  fail | ignore | append_new_columns | sync_all_columns

Practical advice

  • Use append_new_columns for additive, backward-compatible changes.
  • Use fail in strict CI to force a conscious --full-refresh or migration.
  • Do not assume sync_all_columns is free or perfectly portable across warehouses.

Interview tip: Schema evolution on incremental tables is a production topic. Mention you pick a policy deliberately instead of discovering missing columns months later.

PreviousNext