From 2d633d2c12dfa3382516a1df3ce2964aa61f930c Mon Sep 17 00:00:00 2001 From: Tim Vergenz Date: Thu, 27 Nov 2025 04:45:33 -0500 Subject: [PATCH 1/2] fix: materialized_view with persist_docs not updating existing comments ref: https://github.com/databricks/dbt-databricks/discussions/1275 --- dbt/include/databricks/macros/adapters/persist_docs.sql | 3 ++- .../databricks/macros/materializations/materialized_view.sql | 2 ++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/dbt/include/databricks/macros/adapters/persist_docs.sql b/dbt/include/databricks/macros/adapters/persist_docs.sql index da3734ea1..d483a536b 100644 --- a/dbt/include/databricks/macros/adapters/persist_docs.sql +++ b/dbt/include/databricks/macros/adapters/persist_docs.sql @@ -43,7 +43,8 @@ {% endmacro %} {% macro alter_relation_comment_sql(relation, description) %} -COMMENT ON {{ relation.type.render().upper() }} {{ relation.render() }} IS '{{ description | replace("'", "\\'") }}' +{#- ignore relation type; correct keyword is always `TABLE`: https://docs.databricks.com/aws/en/sql/language-manual/sql-ref-syntax-ddl-comment -#} +COMMENT ON TABLE {{ relation.render() }} IS '{{ description | replace("'", "\\'") }}' {% endmacro %} {% macro alter_column_comments(relation, column_dict) %} diff --git a/dbt/include/databricks/macros/materializations/materialized_view.sql b/dbt/include/databricks/macros/materializations/materialized_view.sql index 979b7ac2b..d5a94d843 100644 --- a/dbt/include/databricks/macros/materializations/materialized_view.sql +++ b/dbt/include/databricks/macros/materializations/materialized_view.sql @@ -78,6 +78,8 @@ {% set should_revoke = should_revoke(existing_relation, full_refresh_mode=True) %} {% do apply_grants(target_relation, grant_config, should_revoke=should_revoke) %} + {%- do persist_docs(target_relation, model) %} + {{ run_hooks(post_hooks, inside_transaction=True) }} {% endmacro %} From 509a414ac5ad4d9c6a42fd860ab0c836f220bc43 Mon Sep 17 00:00:00 2001 From: Tim Vergenz Date: Thu, 27 Nov 2025 04:49:13 -0500 Subject: [PATCH 2/2] add to changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 84f58dbc7..5865242e4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,7 @@ ### Fixes - Truncate (128 charactesr max) and escape special characters for default query tag values +- Fix bug where persist_docs did not update existing comments on materialized views ([#1275](https://github.com/databricks/dbt-databricks/discussions/1275)) ## dbt-databricks 1.11.2 (Nov 18, 2025)