Repository: databricks/dbt-databricks
Pull request #981 (2025-03-28 19:50:05)

Migrate comment behavior to relation configs
<!---
  Include the number of the issue addressed by this PR above if applicable.

  Example:
    resolves #1234

  Please review our pull request review process in CONTRIBUTING.md before your proceed.
-->

### Description

The goal here is to ensure we don't make any comment operations if nothing has changed.  We have now adopted this approach for views (if using alter behavior) and incremental (when applying config changes for incremental)

### Checklist

- [x] I have run this code in development and it appears to resolve the stated issue
- [x] This PR includes tests, or tests are not required/relevant for this PR
- [x] I have updated the `CHANGELOG.md` and added information about my change to the "dbt-databricks next" section.



Patch:
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 2e524ed8..25d9dd7c 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -18,6 +18,7 @@
 - Upgrading Databricks SQL Connector to V4 ([962](https://github.com/databricks/dbt-databricks/pull/962))
 - Validation of sample mode ([961](https://github.com/databricks/dbt-databricks/pull/961))
 - Move liquid clustering behavior to on_config_change approach for incremental ([968](https://github.com/databricks/dbt-databricks/pull/968))
+- Move column coments to on_config_change approach ([981](https://github.com/databricks/dbt-databricks/pull/981))
 
 ## dbt-databricks 1.9.8 (TBD)
 
diff --git a/dbt/adapters/databricks/impl.py b/dbt/adapters/databricks/impl.py
index 5bf35b4c..86c95c69 100644
--- a/dbt/adapters/databricks/impl.py
+++ b/dbt/adapters/databricks/impl.py
@@ -934,6 +934,11 @@ class IncrementalTableAPI(RelationAPIBase[IncrementalTableConfig]):
         if not relation.is_hive_metastore():
             results["information_schema.tags"] = adapter.execute_macro("fetch_tags", kwargs=kwargs)
         results["show_tblproperties"] = adapter.execute_macro("fetch_tbl_properties", kwargs=kwargs)
+
+        kwargs = {"table_name": relation}
+        results["describe_extended"] = adapter.execute_macro(
+            DESCRIBE_TABLE_EXTENDED_MACRO_NAME, kwargs=kwargs
+        )
         return results
 
 
diff --git a/dbt/adapters/databricks/relation_configs/column_comments.py b/dbt/adapters/databricks/relation_configs/column_comments.py
new file mode 100644
index 00000000..4c882f54
--- /dev/null
+++ b/dbt/adapters/databricks/relation_configs/column_comments.py
@@ -0,0 +1,62 @@
+from typing import ClassVar, Optional
+
+from dbt.adapters.contracts.relation import RelationConfig
+from dbt.adapters.databricks.logging import logger
+from dbt.adapters.databricks.relation_configs.base import (
+    DatabricksComponentConfig,
+    DatabricksComponentProcessor,
+)
+from dbt.adapters.relation_configs.config_base import RelationResults
+
+
+class ColumnCommentsConfig(DatabricksComponentConfig):
+    """Component encapsulating column-level comments."""
+
+    comments: dict[str, str]
+    quoted: dict[str, bool] = {}
+    persist: bool = False
+
+    def get_diff(self, other: "ColumnCommentsConfig") -> Optional["ColumnCommentsConfig"]:
+        logger.debug(f"Getting diff for ColumnCommentsConfig: {self} and {other}")
+        comments = {}
+        if self.persist:
+            for column_name, comment in self.comments.items():
+                if comment != other.comments.get(column_name.lower()):
+                    column_name = (
+                        f"`{column_name}`" if self.quoted.get(column_name, False) else column_name
+                    )
+                    comments[column_name] = comment
+            logger.debug(f"Comments: {comments}")
+            return ColumnCommentsConfig(comments=comments, persist=True)
+        return None
+
+
+class ColumnCommentsProcessor(DatabricksComponentProcessor[ColumnCommentsConfig]):
+    name: ClassVar[str] = "column_comments"
+
+    @classmethod
+    def from_relation_results(cls, results: RelationResults) -> ColumnCommentsConfig:
+        table = results["describe_extended"]
+        comments = {}
+        for row in table.rows:
+            if row["col_name"].startswith("#"):
+                break
+            comments[row["col_name"].lower()] = row["comment"] or ""
+        return ColumnCommentsConfig(comments=comments)
+
+    @classmethod
+    def from_relation_config(cls, relation_config: RelationConfig) -> ColumnCommentsConfig:
+        columns = getattr(relation_config, "columns", {})
+        persist = False
+        if relation_config.config:
+            persist = relation_config.config.persist_docs.get("relation") or False
+        comments = {}
+        quoted = {}
+        for column_name, column in columns.items():
+            if hasattr(column, "description"):
+                comments[column_name] = column.description or ""
+                quoted[column_name] = column.quote or False
+            else:
+                comments[column_name] = column.get("description", "")
+                quoted[column_name] = column.get("quote", False)
+        return ColumnCommentsConfig(comments=comments, persist=persist, quoted=quoted)
diff --git a/dbt/adapters/databricks/relation_configs/comment.py b/dbt/adapters/databricks/relation_configs/comment.py
index 3dfa07bc..752e8cd0 100644
--- a/dbt/adapters/databricks/relation_configs/comment.py
+++ b/dbt/adapters/databricks/relation_configs/comment.py
@@ -12,6 +12,12 @@ class CommentConfig(DatabricksComponentConfig):
     """Component encapsulating the relation-level comment."""
 
     comment: Optional[str] = None
+    persist: bool = False
+
+    def get_diff(self, other: "CommentConfig") -> Optional["CommentConfig"]:
+        if self.persist and self.comment != other.comment:
+            return self
+        return None
 
 
 class CommentProcessor(DatabricksComponentProcessor[CommentConfig]):
@@ -30,7 +36,10 @@ class CommentProcessor(DatabricksComponentProcessor[CommentConfig]):
 
     @classmethod
     def from_relation_config(cls, relation_config: RelationConfig) -> CommentConfig:
+        persist = False
+        if relation_config.config:
+            persist = relation_config.config.persist_docs.get("relation", False)
         comment = getattr(relation_config, "description", None)
         if comment:
-            return CommentConfig(comment=comment)
-        return CommentConfig()
+            return CommentConfig(comment=comment, persist=persist)
+        return CommentConfig(persist=persist)
diff --git a/dbt/adapters/databricks/relation_configs/incremental.py b/dbt/adapters/databricks/relation_configs/incremental.py
index 7c62fd13..e069e397 100644
--- a/dbt/adapters/databricks/relation_configs/incremental.py
+++ b/dbt/adapters/databricks/relation_configs/incremental.py
@@ -1,10 +1,18 @@
 from dbt.adapters.databricks.relation_configs.base import (
     DatabricksRelationConfigBase,
 )
+from dbt.adapters.databricks.relation_configs.column_comments import ColumnCommentsProcessor
+from dbt.adapters.databricks.relation_configs.comment import CommentProcessor
 from dbt.adapters.databricks.relation_configs.liquid_clustering import LiquidClusteringProcessor
 from dbt.adapters.databricks.relation_configs.tags import TagsProcessor
 from dbt.adapters.databricks.relation_configs.tblproperties import TblPropertiesProcessor
 
 
 class IncrementalTableConfig(DatabricksRelationConfigBase):
-    config_components = [TagsProcessor, TblPropertiesProcessor, LiquidClusteringProcessor]
+    config_components = [
+        CommentProcessor,
+        ColumnCommentsProcessor,
+        TagsProcessor,
+        TblPropertiesProcessor,
+        LiquidClusteringProcessor,
+    ]
diff --git a/dbt/adapters/databricks/relation_configs/liquid_clustering.py b/dbt/adapters/databricks/relation_configs/liquid_clustering.py
index b55d1e40..dd1e2fc3 100644
--- a/dbt/adapters/databricks/relation_configs/liquid_clustering.py
+++ b/dbt/adapters/databricks/relation_configs/liquid_clustering.py
@@ -26,7 +26,7 @@ class LiquidClusteringProcessor(DatabricksComponentProcessor[LiquidClusteringCon
         table = results["show_tblproperties"]
         for row in table.rows:
             if row[0] == "clusterByAuto":
-                cluster_by_auto = bool(row[1])
+                cluster_by_auto = row[1] == "true"
             if row[0] == "clusteringColumns":
                 cluster_by = cls.extract_cluster_by(row[1])
         return LiquidClusteringConfig(cluster_by=cluster_by, auto_cluster=cluster_by_auto)
diff --git a/dbt/adapters/databricks/relation_configs/view.py b/dbt/adapters/databricks/relation_configs/view.py
index 28f83156..ec95d499 100644
--- a/dbt/adapters/databricks/relation_configs/view.py
+++ b/dbt/adapters/databricks/relation_configs/view.py
@@ -7,6 +7,7 @@ from dbt.adapters.databricks.relation_configs.base import (
     DatabricksRelationChangeSet,
     DatabricksRelationConfigBase,
 )
+from dbt.adapters.databricks.relation_configs.column_comments import ColumnCommentsProcessor
 from dbt.adapters.databricks.relation_configs.comment import CommentProcessor
 from dbt.adapters.databricks.relation_configs.query import QueryProcessor
 from dbt.adapters.databricks.relation_configs.tags import TagsProcessor
@@ -14,7 +15,13 @@ from dbt.adapters.databricks.relation_configs.tblproperties import TblProperties
 
 
 class ViewConfig(DatabricksRelationConfigBase):
-    config_components = [TagsProcessor, TblPropertiesProcessor, QueryProcessor, CommentProcessor]
+    config_components = [
+        TagsProcessor,
+        TblPropertiesProcessor,
+        QueryProcessor,
+        CommentProcessor,
+        ColumnCommentsProcessor,
+    ]
 
     def get_changeset(self, existing: Self) -> Optional[DatabricksRelationChangeSet]:
         changeset = super().get_changeset(existing)
diff --git a/dbt/include/databricks/macros/adapters/persist_docs.sql b/dbt/include/databricks/macros/adapters/persist_docs.sql
index 16b5e403..ca39d3c5 100644
--- a/dbt/include/databricks/macros/adapters/persist_docs.sql
+++ b/dbt/include/databricks/macros/adapters/persist_docs.sql
@@ -18,7 +18,7 @@ COMMENT ON COLUMN {{ column_path }} IS '{{ escaped_comment }}'
 
 {% macro databricks__persist_docs(relation, model, for_relation, for_columns) -%}
   {%- if for_relation and config.persist_relation_docs() and model.description %}
-    {{ run_query_as(alter_relation_comment_sql(relation, model), 'alter_relation_comment', fetch_result=False) }}
+    {{ run_query_as(alter_relation_comment_sql(relation, model.description), 'alter_relation_comment', fetch_result=False) }}
   {% endif %}
   {% if for_columns and config.persist_column_docs() and model.columns %}
     {%- set existing_columns = adapter.get_columns_in_relation(relation) -%}
@@ -27,6 +27,15 @@ COMMENT ON COLUMN {{ column_path }} IS '{{ escaped_comment }}'
   {% endif %}
 {% endmacro %}
 
-{% macro alter_relation_comment_sql(relation, model) %}
-COMMENT ON {{ relation.type.upper() }} {{ relation.render() }} IS '{{ model.description | replace("'", "\\'") }}'
+{% macro alter_relation_comment_sql(relation, description) %}
+COMMENT ON {{ relation.type.upper() }} {{ relation.render() }} IS '{{ description | replace("'", "\\'") }}'
+{% endmacro %}
+
+{% macro alter_column_comments(relation, column_dict) %}
+  {% for column, comment in column_dict.items() %}
+    {{ log('Updating comment for column ' ~ column ~ ' with comment ' ~ comment) }}
+    {% set escaped_comment = comment | replace('\'', '\\\'') %}
+    {% set column_path = relation.render() ~ '.' ~ column %}
+    {{ run_query_as(comment_on_column_sql(column_path, escaped_comment), 'alter_column_comment', fetch_result=False) }}
+  {% endfor %}
 {% endmacro %}
\ No newline at end of file
diff --git a/dbt/include/databricks/macros/materializations/incremental/incremental.sql b/dbt/include/databricks/macros/materializations/incremental/incremental.sql
index 3f41d94b..e4d6fddd 100644
--- a/dbt/include/databricks/macros/materializations/incremental/incremental.sql
+++ b/dbt/include/databricks/macros/materializations/incremental/incremental.sql
@@ -152,15 +152,15 @@
       {% if _configuration_changes is not none %}
         {% set tags = _configuration_changes.changes.get("tags", None) %}
         {% set tblproperties = _configuration_changes.changes.get("tblproperties", None) %}
-        {% set liquid_clustering = _configuration_changes.changes.get("liquid_clustered_by") %}
+        {% set liquid_clustering = _configuration_changes.changes.get("liquid_clustering") %}
         {% if tags is not none %}
           {% do apply_tags(target_relation, tags.set_tags, tags.unset_tags) %}
         {%- endif -%}
         {% if tblproperties is not none %}
           {% do apply_tblproperties(target_relation, tblproperties.tblproperties) %}
         {%- endif -%}
-        {% if liquid_clustered_by is not none %}
-          
+        {% if liquid_clustering is not none %}
+          {% do apply_liquid_clustered_cols(target_relation, liquid_clustering) %}
         {% endif %}
       {%- endif -%}
       {% do persist_docs(target_relation, model, for_relation=True) %}
diff --git a/dbt/include/databricks/macros/materializations/view.sql b/dbt/include/databricks/macros/materializations/view.sql
index 10206ea5..10db5033 100644
--- a/dbt/include/databricks/macros/materializations/view.sql
+++ b/dbt/include/databricks/macros/materializations/view.sql
@@ -19,7 +19,6 @@
         {% endif %}
         {# This is to satisfy dbt as there are no changes needed here #}
         {{ execute_no_op(target_relation) }}
-        {{ persist_docs(target_relation, model, for_relation=False) }}
       {% else %}
         {{ replace_with_view(existing_relation, target_relation) }}
       {% endif %}
diff --git a/dbt/include/databricks/macros/relations/comment.sql b/dbt/include/databricks/macros/relations/comment.sql
index 62779a55..8ef37d03 100644
--- a/dbt/include/databricks/macros/relations/comment.sql
+++ b/dbt/include/databricks/macros/relations/comment.sql
@@ -8,4 +8,4 @@
   {%- elif raw_persist_docs -%}
     {{ exceptions.raise_compiler_error("Invalid value provided for 'persist_docs'. Expected dict but got value: " ~ raw_persist_docs) }}
   {% endif %}
-{%- endmacro -%}
\ No newline at end of file
+{%- endmacro -%}
diff --git a/dbt/include/databricks/macros/relations/table/alter.sql b/dbt/include/databricks/macros/relations/table/alter.sql
index dd5f3dfa..92899fa9 100644
--- a/dbt/include/databricks/macros/relations/table/alter.sql
+++ b/dbt/include/databricks/macros/relations/table/alter.sql
@@ -1,6 +1,8 @@
 {% macro apply_config_changeset(target_relation, model, configuration_changes) %}
     {{ log("Applying configuration changes to relation " ~ target_relation) }}
     {% if configuration_changes %}
+      {% set comment = configuration_changes.changes.get("comment") %}
+      {% set column_comments = configuration_changes.changes.get("column_comments") %}
       {% set tags = configuration_changes.changes.get("tags") %}
       {% set tblproperties = configuration_changes.changes.get("tblproperties") %}
       {% set liquid_clustering = configuration_changes.changes.get("liquid_clustering")%}
@@ -13,6 +15,11 @@
       {% if liquid_clustering is not none %}
         {% do apply_liquid_clustered_cols(target_relation, liquid_clustering) %}
       {%- endif -%}
+      {% if comment %}
+        {{ run_query_as(alter_relation_comment_sql(target_relation, comment.comment), 'alter_relation_comment', fetch_result=False) }}
+      {% endif %}
+      {% if column_comments %}
+        {{ alter_column_comments(target_relation, column_comments.comments) }}
+      {% endif %}
     {%- endif -%}
-    {% do persist_docs(target_relation, model, for_relation=True) %}
 {% endmacro %}
\ No newline at end of file
diff --git a/dbt/include/databricks/macros/relations/view/alter.sql b/dbt/include/databricks/macros/relations/view/alter.sql
index 858a9dce..229e9fb7 100644
--- a/dbt/include/databricks/macros/relations/view/alter.sql
+++ b/dbt/include/databricks/macros/relations/view/alter.sql
@@ -7,6 +7,7 @@
   {% set tags = changes.get("tags") %}
   {% set tblproperties = changes.get("tblproperties") %}
   {% set query = changes.get("query") %}
+  {% set column_comments = changes.get("column_comments") %}
   {% if tags %}
     {{ apply_tags(target_relation, tags.set_tags, tags.unset_tags) }}
   {% endif %}
@@ -16,4 +17,7 @@
   {% if query %}
     {{ alter_query(target_relation, query.query) }}
   {% endif %}
+  {% if column_comments %}
+    {{ alter_column_comments(target_relation, column_comments.comments) }}
+  {% endif %}
 {% endmacro %}


Test patch:
diff --git a/tests/functional/adapter/incremental/test_incremental_persist_docs.py b/tests/functional/adapter/incremental/test_incremental_persist_docs.py
index a2e02b8c..4c5e6255 100644
--- a/tests/functional/adapter/incremental/test_incremental_persist_docs.py
+++ b/tests/functional/adapter/incremental/test_incremental_persist_docs.py
@@ -41,3 +41,19 @@ class TestIncrementalPersistDocs:
         )
         assert results[0][2] == "This is the id column"
         assert results[1][2] == "This is the msg column"
+
+
+class TestIncrementalPersistDocsV2(TestIncrementalPersistDocs):
+    @pytest.fixture(scope="class")
+    def project_config_update(self):
+        return {
+            "flags": {"use_materialization_v2": True},
+            "models": {
+                "test": {
+                    "+persist_docs": {
+                        "relation": True,
+                        "columns": True,
+                    },
+                }
+            },
+        }
diff --git a/tests/unit/macros/adapters/test_persist_docs_macros.py b/tests/unit/macros/adapters/test_persist_docs_macros.py
index 800ca10c..982bbe84 100644
--- a/tests/unit/macros/adapters/test_persist_docs_macros.py
+++ b/tests/unit/macros/adapters/test_persist_docs_macros.py
@@ -14,12 +14,6 @@ class TestPersistDocsMacros(MacroTestBase):
     def macro_folders_to_load(self) -> list:
         return ["macros", "macros/adapters"]
 
-    @pytest.fixture
-    def mock_model_with_description(self):
-        model = Mock()
-        model.description = "This is a test model"
-        return model
-
     @pytest.fixture
     def mock_model_with_columns(self):
         model = Mock()
@@ -44,27 +38,22 @@ class TestPersistDocsMacros(MacroTestBase):
         """
         self.assert_sql_equal(result, expected_sql)
 
-    def test_alter_relation_comment_sql(
-        self, template_bundle, relation, mock_model_with_description
-    ):
+    def test_alter_relation_comment_sql(self, template_bundle, relation):
         result = self.run_macro(
             template_bundle.template,
             "alter_relation_comment_sql",
             relation,
-            mock_model_with_description,
+            "This is a test model",
         )
 
         expected_sql = (
             "COMMENT ON TABLE `some_database`.`some_schema`.`some_table` IS 'This is a test model'"
         )
-        self.assert_sql_equal(result, expected_sql)
+        self.assert_sql_equal(expected_sql, result)
 
     def test_alter_relation_comment_sql_with_quotes(self, template_bundle, relation):
-        model = Mock()
-        model.description = "Model with 'quotes'"
-
         result = self.run_macro(
-            template_bundle.template, "alter_relation_comment_sql", relation, model
+            template_bundle.template, "alter_relation_comment_sql", relation, "Model with 'quotes'"
         )
 
         expected_sql = (
@@ -73,7 +62,7 @@ class TestPersistDocsMacros(MacroTestBase):
         )
         self.assert_sql_equal(result, expected_sql)
 
-    def test_alter_relation_comment_sql_view(self, template_bundle, mock_model_with_description):
+    def test_alter_relation_comment_sql_view(self, template_bundle):
         view_relation = Mock()
         view_relation.database = "test_db"
         view_relation.schema = "test_schema"
@@ -85,7 +74,7 @@ class TestPersistDocsMacros(MacroTestBase):
             template_bundle.template,
             "alter_relation_comment_sql",
             view_relation,
-            mock_model_with_description,
+            "This is a test model",
         )
 
         expected_sql = (
@@ -150,19 +139,21 @@ class TestPersistDocsMacros(MacroTestBase):
             "but file format parquet does not support that."
         )
 
-    def test_databricks__persist_docs_relation_only(
-        self, template_bundle, context, relation, mock_model_with_description
-    ):
+    def test_databricks__persist_docs_relation_only(self, template_bundle, context, relation):
         context["config"] = MagicMock()
         context["config"].persist_relation_docs.return_value = True
 
+        # Create a model with a description
+        model = Mock()
+        model.description = "This is a test model"
+
         context["run_query_as"] = Mock()
 
         self.run_macro_raw(
             template_bundle.template,
             "databricks__persist_docs",
             relation,
-            mock_model_with_description,
+            model,
             True,  # for_relation
             False,  # for_columns
         )
diff --git a/tests/unit/relation_configs/test_comment.py b/tests/unit/relation_configs/test_comment.py
index 71d80207..7e9de2df 100644
--- a/tests/unit/relation_configs/test_comment.py
+++ b/tests/unit/relation_configs/test_comment.py
@@ -46,17 +46,39 @@ class TestCommentProcessor:
     def test_from_model_node__no_comment(self):
         model_node = Mock()
         model_node.description = None
+        model_node.config.persist_docs = {"relation": True, "columns": False}
         config = CommentProcessor.from_relation_config(model_node)
-        assert config == CommentConfig()
+        assert config == CommentConfig(persist=True)
 
     def test_from_model_node__empty_comment(self):
         model_node = Mock()
         model_node.description = ""
+        model_node.config.persist_docs = {}
+
         config = CommentProcessor.from_relation_config(model_node)
-        assert config == CommentConfig(comment=None)
+        assert config == CommentConfig(comment=None, persist=False)
 
     def test_from_model_node__comment(self):
         model_node = Mock()
         model_node.description = "a comment"
+        model_node.config.persist_docs = {"relation": True, "columns": False}
+
         config = CommentProcessor.from_relation_config(model_node)
-        assert config == CommentConfig(comment="a comment")
+        assert config == CommentConfig(comment="a comment", persist=True)
+
+
+class TestCommentConfig:
+    def test_comment_config_get_diff__no_changes(self):
+        current = CommentConfig(comment="test comment")
+        target = CommentConfig(comment="test comment", persist=True)
+        assert target.get_diff(current) is None
+
+    def test_comment_config_get_diff__comment_changed(self):
+        current = CommentConfig(comment="old comment")
+        target = CommentConfig(comment="new comment", persist=True)
+        assert target.get_diff(current) == target
+
+    def test_comment_config_get_diff__no_persist(self):
+        current = CommentConfig(comment="test comment")
+        target = CommentConfig(comment="test comment", persist=False)
+        assert target.get_diff(current) is None
diff --git a/tests/unit/relation_configs/test_incremental_config.py b/tests/unit/relation_configs/test_incremental_config.py
index 39fee754..907f8ebc 100644
--- a/tests/unit/relation_configs/test_incremental_config.py
+++ b/tests/unit/relation_configs/test_incremental_config.py
@@ -1,5 +1,7 @@
 from agate import Table
 
+from dbt.adapters.databricks.relation_configs.column_comments import ColumnCommentsConfig
+from dbt.adapters.databricks.relation_configs.comment import CommentConfig
 from dbt.adapters.databricks.relation_configs.incremental import IncrementalTableConfig
 from dbt.adapters.databricks.relation_configs.liquid_clustering import LiquidClusteringConfig
 from dbt.adapters.databricks.relation_configs.tags import TagsConfig
@@ -24,13 +26,23 @@ class TestIncrementalConfig:
                 ],
                 column_names=["key", "value"],
             ),
+            "describe_extended": Table(
+                rows=[
+                    ["column", "string", "test comment"],
+                ],
+                column_names=["col_name", "col_type", "comment"],
+            ),
         }
 
         config = IncrementalTableConfig.from_results(results)
 
         assert config == IncrementalTableConfig(
             config={
+                "comment": CommentConfig(comment=None, persist=False),
                 "tags": TagsConfig(set_tags={"tag1": "value1", "tag2": "value2"}),
+                "column_comments": ColumnCommentsConfig(
+                    comments={"column": "test comment"}, quoted={}, persist=False
+                ),
                 "tblproperties": TblPropertiesConfig(tblproperties={"prop": "f1"}),
                 "liquid_clustering": LiquidClusteringConfig(
                     auto_cluster=True,
diff --git a/tests/unit/relation_configs/test_materialized_view_config.py b/tests/unit/relation_configs/test_materialized_view_config.py
index 09aa9571..7d50da92 100644
--- a/tests/unit/relation_configs/test_materialized_view_config.py
+++ b/tests/unit/relation_configs/test_materialized_view_config.py
@@ -61,6 +61,7 @@ class TestMaterializedViewConfig:
                 "other": "other",
             },
         }
+        model.config.persist_docs = {"relation": True, "columns": False}
         model.description = "This is the table comment"
 
         config = MaterializedViewConfig.from_relation_config(model)
@@ -68,7 +69,7 @@ class TestMaterializedViewConfig:
         assert config == MaterializedViewConfig(
             config={
                 "partition_by": PartitionedByConfig(partition_by=["col_a", "col_b"]),
-                "comment": CommentConfig(comment="This is the table comment"),
+                "comment": CommentConfig(comment="This is the table comment", persist=True),
                 "tblproperties": TblPropertiesConfig(tblproperties={"prop": "1", "other": "other"}),
                 "refresh": RefreshConfig(),
                 "query": QueryConfig(query="select * from foo"),
diff --git a/tests/unit/relation_configs/test_streaming_table_config.py b/tests/unit/relation_configs/test_streaming_table_config.py
index 2ad77763..cc3e299f 100644
--- a/tests/unit/relation_configs/test_streaming_table_config.py
+++ b/tests/unit/relation_configs/test_streaming_table_config.py
@@ -48,6 +48,7 @@ class TestStreamingTableConfig:
                 "other": "other",
             },
         }
+        model.config.persist_docs = {"relation": False, "columns": True}
         model.description = "This is the table comment"
 
         config = StreamingTableConfig.from_relation_config(model)
@@ -55,7 +56,7 @@ class TestStreamingTableConfig:
         assert config == StreamingTableConfig(
             config={
                 "partition_by": PartitionedByConfig(partition_by=["col_a", "col_b"]),
-                "comment": CommentConfig(comment="This is the table comment"),
+                "comment": CommentConfig(comment="This is the table comment", persist=False),
                 "tblproperties": TblPropertiesConfig(tblproperties={"prop": "1", "other": "other"}),
                 "refresh": RefreshConfig(),
             }