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) 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 %}