Skip to content

fix: incremental materialization silently fallback to inserts only - #802

Merged
canbekley merged 5 commits into
mainfrom
fix/incremental-materialization-silently-fallback-to-inserts-only
Nov 16, 2026
Merged

canbekley merged 5 commits into
mainfrom
fix/incremental-materialization-silently-fallback-to-inserts-only

Conversation

@canbekley

@canbekley canbekley commented Nov 14, 2026 •

Copy link
Copy Markdown
Contributor

resolves #258

Summary

When no unique_key was set, the incremental materialization (on non-distributed path) did fall back to inserts_only mode, ignoring the incremental strategy, schema changes and potentially creating duplicate rows.

This PR fixes this issue via the following changes:

  • not setting a unique_key on incremental materialization no longer falls back to the inserts_only mode. users who previously relied on this behavior when setting explicit incremental strategies that require unique_key will now see a validation error instead of the silent fallback.
  • the default incremental strategy when no unique_key is defined is now append (now aligned with other adapters and default__get_incremental_default_sql). the previous defaults delete+insert (with lw deletes) and legacy (without lw deletes) did silently fall back to inserts_only (which is replaced by append), so the default materialization behavior doesn't practically change. because append doesn't handle incremental_predicates, it will fail the validation if configured (e.g. this will now fail: config(materialized='incremental', incremental_predicates=['1 = 1'])).
  • strategy validation via adapter.validate_incremental_strategy now runs early on every materialization, even in full-refresh or initial materializations. previously the validation was only triggered on the branches that run the incremental strategy. this gives users an early feedback whether their model is misconfigured.
  • append and inserts_only "strategies" no longer insert into wrong columns when new columns are added out of order or existing column order is changed. this resolves the issue mentioned in the comment of 258.

Checklist

Delete items not relevant to your PR:

  • Unit and integration tests covering the common scenarios were added
  • A changelog entry was added following Updating the Changelog (user-facing, concise, PR link)
  • For significant changes, documentation in docs was updated with further explanations or tutorials

Note

Medium Risk
Changes default incremental behavior and turns previously silent misconfigurations into hard failures, which may break existing projects that relied on fallback append or missing-key strategies.

Overview
Fixes incremental models without a unique_key no longer silently falling back to append-only behavior that ignored incremental_strategy, schema-change handling, and could duplicate rows.

Default strategy is now append when no unique_key is set (via calculate_incremental_strategy); with a unique_key, defaults remain delete+insert or legacy based on use_lw_deletes. inserts_only is deprecated in favor of incremental_strategy='append', with a warning that fails runs under --warn-error.

Validation runs at materialization start (including first/full refresh), not only on incremental branches. Models that set legacy, delete+insert, or microbatch without unique_key now fail with a clear error instead of appending. incremental_predicates with non–delete+insert/microbatch strategies (including default append) also fail validation.

Append/inserts_only inserts now call clickhouse__insert_into with use_columns_from_sql=True so column order matches the model SQL. Docs and changelog reflect the new defaults and requirements; tests cover deprecation, validation failures, and append/schema-change behavior.

Reviewed by Cursor Bugbot for commit 62cbde0. Bugbot is set up for automated code reviews on this repo. Configure here.

@canbekley
canbekley requested a review from koletzilla November 14, 2026 08:40
@workflow-authentication-public workflow-authentication-public Bot added the needs-docs PR has user-visible changes without matching docs updates label Nov 14, 2026
@workflow-authentication-public

workflow-authentication-public Bot commented Nov 14, 2026 •

Copy link
Copy Markdown

Docs drift check: resolved, docs now match this PR's changes.

@canbekley canbekley removed the needs-docs PR has user-visible changes without matching docs updates label Nov 14, 2026
@koletzilla
koletzilla self-requested a review November 16, 2026 12:10
@koletzilla
koletzilla dismissed their stale review November 16, 2026 12:10

Checking how it solves 258

Comment thread CHANGELOG.md Resolved
@canbekley
canbekley merged commit e563957 into main Nov 16, 2026
18 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Cannot add new columns to incremental models

2 participants