From c7781a45d08628d92a8d674c8cb2bc5f4bc20a64 Mon Sep 17 00:00:00 2001 From: Mike Alfare Date: Fri, 14 Jun 2024 14:09:57 -0400 Subject: [PATCH] remove comment from relation parsing since it's handled via persist_docs --- .../unreleased/Features-20240131-125318.yaml | 2 +- dbt/adapters/snowflake/relation.py | 7 ------- .../snowflake/relation_configs/__init__.py | 1 - .../relation_configs/dynamic_table.py | 18 +----------------- .../macros/relations/dynamic_table/create.sql | 3 --- .../relations/dynamic_table/describe.sql | 3 +-- .../macros/relations/dynamic_table/replace.sql | 3 --- 7 files changed, 3 insertions(+), 34 deletions(-) diff --git a/.changes/unreleased/Features-20240131-125318.yaml b/.changes/unreleased/Features-20240131-125318.yaml index 75de2812e..a2e3b8f51 100644 --- a/.changes/unreleased/Features-20240131-125318.yaml +++ b/.changes/unreleased/Features-20240131-125318.yaml @@ -1,5 +1,5 @@ kind: Features -body: Support refresh_mode, initialize, and comment parameters for dynamic tables +body: Support refresh_mode and initialize parameters for dynamic tables time: 2024-01-31T12:53:18.111616Z custom: Author: HenkvanDyk diff --git a/dbt/adapters/snowflake/relation.py b/dbt/adapters/snowflake/relation.py index 0bfd4a8ca..f477265f0 100644 --- a/dbt/adapters/snowflake/relation.py +++ b/dbt/adapters/snowflake/relation.py @@ -14,7 +14,6 @@ from dbt.adapters.snowflake.relation_configs import ( SnowflakeDynamicTableConfig, SnowflakeDynamicTableConfigChangeset, - SnowflakeDynamicTableCommentConfigChange, SnowflakeDynamicTableRefreshModeConfigChange, SnowflakeDynamicTableTargetLagConfigChange, SnowflakeDynamicTableWarehouseConfigChange, @@ -104,12 +103,6 @@ def dynamic_table_config_changeset( context=new_dynamic_table.refresh_mode, ) - if new_dynamic_table.comment != existing_dynamic_table.comment: - config_change_collection.comment = SnowflakeDynamicTableCommentConfigChange( - action=RelationConfigChangeAction.alter, - context=new_dynamic_table.comment, - ) - if config_change_collection.has_changes: return config_change_collection return None diff --git a/dbt/adapters/snowflake/relation_configs/__init__.py b/dbt/adapters/snowflake/relation_configs/__init__.py index 40c9d3fe1..62f95faff 100644 --- a/dbt/adapters/snowflake/relation_configs/__init__.py +++ b/dbt/adapters/snowflake/relation_configs/__init__.py @@ -1,7 +1,6 @@ from dbt.adapters.snowflake.relation_configs.dynamic_table import ( SnowflakeDynamicTableConfig, SnowflakeDynamicTableConfigChangeset, - SnowflakeDynamicTableCommentConfigChange, SnowflakeDynamicTableRefreshModeConfigChange, SnowflakeDynamicTableWarehouseConfigChange, SnowflakeDynamicTableTargetLagConfigChange, diff --git a/dbt/adapters/snowflake/relation_configs/dynamic_table.py b/dbt/adapters/snowflake/relation_configs/dynamic_table.py index b40f897e4..2e227d3a4 100644 --- a/dbt/adapters/snowflake/relation_configs/dynamic_table.py +++ b/dbt/adapters/snowflake/relation_configs/dynamic_table.py @@ -45,7 +45,6 @@ class SnowflakeDynamicTableConfig(SnowflakeRelationConfigBase): - snowflake_warehouse: the name of the warehouse that provides the compute resources for refreshing the dynamic table - refresh_mode: specifies the refresh type for the dynamic table - initialize: specifies the behavior of the initial refresh of the dynamic table - - comment: specifies a comment for the dynamic table There are currently no non-configurable parameters. """ @@ -58,7 +57,6 @@ class SnowflakeDynamicTableConfig(SnowflakeRelationConfigBase): snowflake_warehouse: str refresh_mode: Optional[RefreshMode] = RefreshMode.default() initialize: Optional[Initialize] = Initialize.default() - comment: Optional[str] = None @classmethod def from_dict(cls, config_dict) -> "SnowflakeDynamicTableConfig": @@ -73,7 +71,6 @@ def from_dict(cls, config_dict) -> "SnowflakeDynamicTableConfig": "snowflake_warehouse": config_dict.get("snowflake_warehouse"), "refresh_mode": config_dict.get("refresh_mode"), "initialize": config_dict.get("initialize"), - "comment": config_dict.get("comment"), } dynamic_table: "SnowflakeDynamicTableConfig" = super().from_dict(kwargs_dict) @@ -88,7 +85,6 @@ def parse_relation_config(cls, relation_config: RelationConfig) -> Dict[str, Any "query": relation_config.compiled_code, "target_lag": relation_config.config.extra.get("target_lag"), "snowflake_warehouse": relation_config.config.extra.get("snowflake_warehouse"), - "comment": relation_config.config.extra.get("comment"), } if refresh_mode := relation_config.config.extra.get("refresh_mode"): @@ -111,7 +107,6 @@ def parse_relation_results(cls, relation_results: RelationResults) -> Dict: "target_lag": dynamic_table.get("target_lag"), "snowflake_warehouse": dynamic_table.get("warehouse"), "refresh_mode": dynamic_table.get("refresh_mode"), - "comment": dynamic_table.get("comment"), # we don't get initialize since that's a one-time scheduler attribute, not a DT attribute } @@ -145,21 +140,11 @@ def requires_full_refresh(self) -> bool: return True -@dataclass(frozen=True, eq=True, unsafe_hash=True) -class SnowflakeDynamicTableCommentConfigChange(RelationConfigChange): - context: Optional[str] = None - - @property - def requires_full_refresh(self) -> bool: - return False - - @dataclass class SnowflakeDynamicTableConfigChangeset: target_lag: Optional[SnowflakeDynamicTableTargetLagConfigChange] = None snowflake_warehouse: Optional[SnowflakeDynamicTableWarehouseConfigChange] = None refresh_mode: Optional[SnowflakeDynamicTableRefreshModeConfigChange] = None - comment: Optional[SnowflakeDynamicTableCommentConfigChange] = None @property def requires_full_refresh(self) -> bool: @@ -172,10 +157,9 @@ def requires_full_refresh(self) -> bool: else False ), self.refresh_mode.requires_full_refresh if self.refresh_mode else False, - self.comment.requires_full_refresh if self.comment else False, ] ) @property def has_changes(self) -> bool: - return any([self.target_lag, self.snowflake_warehouse, self.refresh_mode, self.comment]) + return any([self.target_lag, self.snowflake_warehouse, self.refresh_mode]) diff --git a/dbt/include/snowflake/macros/relations/dynamic_table/create.sql b/dbt/include/snowflake/macros/relations/dynamic_table/create.sql index 981568cf8..253788779 100644 --- a/dbt/include/snowflake/macros/relations/dynamic_table/create.sql +++ b/dbt/include/snowflake/macros/relations/dynamic_table/create.sql @@ -11,9 +11,6 @@ {% if dynamic_table.initialize %} initialize = {{ dynamic_table.initialize }} {% endif %} - {% if dynamic_table.comment %} - comment = '{{ dynamic_table.comment }}' - {% endif %} as ( {{ sql }} ) diff --git a/dbt/include/snowflake/macros/relations/dynamic_table/describe.sql b/dbt/include/snowflake/macros/relations/dynamic_table/describe.sql index c8ba0c9a7..cc79328fe 100644 --- a/dbt/include/snowflake/macros/relations/dynamic_table/describe.sql +++ b/dbt/include/snowflake/macros/relations/dynamic_table/describe.sql @@ -11,8 +11,7 @@ "text", "target_lag", "warehouse", - "refresh_mode", - "comment" + "refresh_mode" from table(result_scan(last_query_id())) {%- endset %} {% set _dynamic_table = run_query(_dynamic_table_sql) %} diff --git a/dbt/include/snowflake/macros/relations/dynamic_table/replace.sql b/dbt/include/snowflake/macros/relations/dynamic_table/replace.sql index e49fb7cae..dbe27d66e 100644 --- a/dbt/include/snowflake/macros/relations/dynamic_table/replace.sql +++ b/dbt/include/snowflake/macros/relations/dynamic_table/replace.sql @@ -11,9 +11,6 @@ {% if dynamic_table.initialize %} initialize = {{ dynamic_table.initialize }} {% endif %} - {% if dynamic_table.comment %} - comment = '{{ dynamic_table.comment }}' - {% endif %} as ( {{ sql }} )