Skip to content

fix: implicit view schema changes with alter view approach#1358

Open
canbekley wants to merge 2 commits intodatabricks:mainfrom
canbekley:fix/alter-view-not-applied-on-implicit-changes
Open

fix: implicit view schema changes with alter view approach#1358
canbekley wants to merge 2 commits intodatabricks:mainfrom
canbekley:fix/alter-view-not-applied-on-implicit-changes

Conversation

@canbekley
Copy link
Copy Markdown
Contributor

@canbekley canbekley commented Mar 13, 2026

Resolves #1356

Note

Stacked on #1444 (resolves #1357), per maintainer request to split this work. please merge that PR first

Description

Views materialized with view_update_via_alter (v2 materialization) were skipping ALTER VIEW AS whenever dbt's query diff reported no change, so changes in underlying tables (e.g. a new column appearing in a select * source) never propagated to the view.

Fix: force ALTER VIEW AS <query> on every invocation by replacing QueryProcessor with a ViewQueryProcessor whose get_diff always returns self. Drop the no-op branch in the view materialization (always alter, never skip).

With #1357's reapply-after-alter_query block now in place, the existing ColumnCommentsProcessor is also removed from ViewConfig every alter-view run wipes column comments and reapplies them unconditionally, so a separate diff path is no longer needed.

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.

@tejassp-db
Copy link
Copy Markdown
Collaborator

Thanks for the PR. Will look into it.

@tejassp-db tejassp-db self-assigned this Apr 21, 2026
Copy link
Copy Markdown
Collaborator

@tejassp-db tejassp-db left a comment

Choose a reason for hiding this comment

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

It looks like there are two different fixes - column comments and view refresh, in this PR. Can you please split it into two separate PRs?

{% if column_comments %}
{{ alter_column_comments(target_relation, column_comments.comments) }}
{% if config.persist_column_docs() and model.columns %}
{#-- ALTER VIEW AS <query> will wipe all column comments in a column_list, so we need to reapply them here. --#}
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.

Can you explain this comment please?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

that's the issue described in #1357. basically every ALTER VIEW AS command that changes the view defintion will currently (as of dbr 18.1) drop all existing column comments, without adding them back. this issue already existed, but #1356 makes #1357 strictly worse, because we would run ALTER VIEW AS on every invocation.

@canbekley
Copy link
Copy Markdown
Contributor Author

It looks like there are two different fixes - column comments and view refresh, in this PR. Can you please split it into two separate PRs?

good point, I should definitely split this in two separate PRs. there is going to be an order dependency though, as we would need to merge the column comment fix before the bahavioural changes that enforce ALTER VIEW AS invocations. I will create a new PR for the column comment fix.

@canbekley canbekley force-pushed the fix/alter-view-not-applied-on-implicit-changes branch from d485235 to 1dca899 Compare May 8, 2026 09:06
@canbekley canbekley requested a review from jprakash-db as a code owner May 8, 2026 09:06
@canbekley canbekley changed the title fix: view_update_via_alter drops column comments and misses upstream schema changes fix: implicit view schema changes with alter view approach May 8, 2026
@canbekley canbekley requested a review from tejassp-db May 8, 2026 09:17
@canbekley
Copy link
Copy Markdown
Contributor Author

hi @tejassp-db , this PRs is now split into two dependent PRs: column comment fix in #1444 (which would need to be merged first) and the view schema refresh fix in the PR. I also updated the descriptions accordingly. could you please have another look?

canbekley added 2 commits May 8, 2026 11:31
Signed-off-by: Can Bekleyici <can.bekleyici@deepl.com>
Signed-off-by: Can Bekleyici <can.bekleyici@deepl.com>
@canbekley canbekley force-pushed the fix/alter-view-not-applied-on-implicit-changes branch from 1dca899 to d35b3d4 Compare May 8, 2026 09:35
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 views with star-select semantics and config 'view_update_via_alter' are not being updated

2 participants