Skip to content

fix: missing column comments after ALTER VIEW AS#1444

Open
canbekley wants to merge 1 commit intodatabricks:mainfrom
canbekley:fix/view-alter-drops-column-comments
Open

fix: missing column comments after ALTER VIEW AS#1444
canbekley wants to merge 1 commit intodatabricks:mainfrom
canbekley:fix/view-alter-drops-column-comments

Conversation

@canbekley
Copy link
Copy Markdown
Contributor

Resolves #1357

Split out from #1358 per maintainer request to land independently of the #1356 behavior change.

Description

When view_update_via_alter is enabled and the alter path issues ALTER VIEW <view> AS <query>,
Databricks silently drops every persisted column comment. The existing if column_comments block
in databricks__alter_view doesn't catch this because the column-comment diff is computed against
the pre-alter state — when model and existing comments match, the diff is empty, so nothing
reapplies them after ALTER VIEW AS wipes them.

Fix: inside the query branch of databricks__alter_view, reapply persisted column comments
after alter_query, gated on config.persist_column_docs() and model.columns. The pattern
mirrors databricks__persist_docs (dbt/include/databricks/macros/adapters/persist_docs.sql).

The existing if column_comments block is kept — it still handles the disjoint case where only a
column description changed in schema.yml (no query change, so the new reapply path doesn't run).

This fix becomes load-bearing once #1356 lands and ALTER VIEW AS runs on every invocation, but
the bug exists today on any query change and is worth fixing standalone.

Checklist

  • I have run this code in development and it appears to resolve the stated issue
  • This PR includes tests, or tests are not required/relevant for this PR
  • I have updated the CHANGELOG.md and added information about my change to the
    "dbt-databricks next" section.

Signed-off-by: Can Bekleyici <can.bekleyici@deepl.com>
@canbekley canbekley force-pushed the fix/view-alter-drops-column-comments branch from 62e688f to c02466f Compare May 8, 2026 09:31
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.

view query updates via alter view wipes column comments

1 participant