Skip to content

fix: missing column comments after ALTER VIEW AS#1444

Merged
sd-db merged 2 commits into
databricks:mainfrom
canbekley:fix/view-alter-drops-column-comments
Jun 24, 2026
Merged

fix: missing column comments after ALTER VIEW AS#1444
sd-db merged 2 commits into
databricks: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
Resolve conflict in tests/unit/macros/relations/test_view_macros.py by
keeping both additions: this branch's alter_column_comment mock + the
reapplies_column_comments test, and main's (databricks#1526) apply_column_tags mock
+ the column_tags test. They are independent.

Relocate the databricks#1357 CHANGELOG entry out of the now-released 1.11.8 section
into the current 1.12.2 (TBD) Fixes section (main has since released
1.11.8/1.12.0/1.12.1).
@github-actions

Copy link
Copy Markdown

Coverage report

This PR does not seem to contain any modification to coverable code.

@sd-db sd-db left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changes look good, thanks for the PR !!

@sd-db sd-db merged commit 90cda11 into databricks:main Jun 24, 2026
9 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.

view query updates via alter view wipes column comments

2 participants