Skip to content

Commit

Permalink
remove comment from relation parsing since it's handled via persist_docs
Browse files Browse the repository at this point in the history
  • Loading branch information
mikealfare committed Jun 14, 2024
1 parent 8606770 commit c7781a4
Show file tree
Hide file tree
Showing 7 changed files with 3 additions and 34 deletions.
2 changes: 1 addition & 1 deletion .changes/unreleased/Features-20240131-125318.yaml
Original file line number Diff line number Diff line change
@@ -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
Expand Down
7 changes: 0 additions & 7 deletions dbt/adapters/snowflake/relation.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
from dbt.adapters.snowflake.relation_configs import (
SnowflakeDynamicTableConfig,
SnowflakeDynamicTableConfigChangeset,
SnowflakeDynamicTableCommentConfigChange,
SnowflakeDynamicTableRefreshModeConfigChange,
SnowflakeDynamicTableTargetLagConfigChange,
SnowflakeDynamicTableWarehouseConfigChange,
Expand Down Expand Up @@ -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
1 change: 0 additions & 1 deletion dbt/adapters/snowflake/relation_configs/__init__.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
from dbt.adapters.snowflake.relation_configs.dynamic_table import (
SnowflakeDynamicTableConfig,
SnowflakeDynamicTableConfigChangeset,
SnowflakeDynamicTableCommentConfigChange,
SnowflakeDynamicTableRefreshModeConfigChange,
SnowflakeDynamicTableWarehouseConfigChange,
SnowflakeDynamicTableTargetLagConfigChange,
Expand Down
18 changes: 1 addition & 17 deletions dbt/adapters/snowflake/relation_configs/dynamic_table.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
"""
Expand All @@ -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":
Expand All @@ -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)
Expand All @@ -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"):
Expand All @@ -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
}

Expand Down Expand Up @@ -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:
Expand All @@ -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])
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,6 @@
{% if dynamic_table.initialize %}
initialize = {{ dynamic_table.initialize }}
{% endif %}
{% if dynamic_table.comment %}
comment = '{{ dynamic_table.comment }}'
{% endif %}
as (
{{ sql }}
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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) %}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,6 @@
{% if dynamic_table.initialize %}
initialize = {{ dynamic_table.initialize }}
{% endif %}
{% if dynamic_table.comment %}
comment = '{{ dynamic_table.comment }}'
{% endif %}
as (
{{ sql }}
)
Expand Down

0 comments on commit c7781a4

Please sign in to comment.