Skip to content

fix: recreate materialized views on query schema drift - #1621

Open
sd-db wants to merge 3 commits into
mainfrom
sd-db/fix/issue-1359-mv-schema-drift
Open

fix: recreate materialized views on query schema drift#1621
sd-db wants to merge 3 commits into
mainfrom
sd-db/fix/issue-1359-mv-schema-drift

Conversation

@sd-db

@sd-db sd-db commented Jul 30, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • Detect when a materialized view's create-time column list no longer matches the query-inferred schema (e.g. upstream select * gains a column) and recreate via replace instead of issuing REFRESH, which Databricks rejects with an incompatible user-specified schema error.
  • Names-only comparison by design (type-label variance across DESCRIBE paths would cause spurious recreates). Streaming tables (dbt streaming_table fails on schema evolution while native streaming table works #1303) are intentionally out of scope — they need a different approach around locking columns on CREATE.

Resolves #1359

Test plan

  • Unit: tests/unit/test_column_schemas_differ.py
  • Functional (SQL warehouse): tests/functional/adapter/materialized_view_tests/test_mv_schema_evolution.py
  • Smoke: existing test_mv_alter_no_rebuild still passes
  • CI integration tests

When CREATE embeds a user-specified column list, Databricks rejects
REFRESH if the query-inferred schema changes (e.g. upstream select *
gains a column). Detect drift and replace instead of refresh.
@sd-db
sd-db requested a review from jprakash-db as a code owner July 30, 2026 11:52
@github-actions

Copy link
Copy Markdown

Coverage report

Click to see where and how coverage changed

FileStatementsMissingCoverageCoverage
(new stmts)
Lines missing
  dbt/adapters/databricks
  impl.py
Project Total  

This report was generated by python-coverage-comment-action

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.

Adding column to materialized view properties YAML failed to trigger full refresh

1 participant