From eb34007f9c214c6e1e210ff7565a722d095dfbec Mon Sep 17 00:00:00 2001 From: Matthew McKnight Date: Thu, 14 Sep 2023 14:33:01 -0500 Subject: [PATCH] fill out changeset and config change classes for specific options --- .../relation_configs/materialized_view.py | 48 ++++++++++++++++++- 1 file changed, 46 insertions(+), 2 deletions(-) diff --git a/dbt/adapters/bigquery/relation_configs/materialized_view.py b/dbt/adapters/bigquery/relation_configs/materialized_view.py index 975b40c88..d5e489f14 100644 --- a/dbt/adapters/bigquery/relation_configs/materialized_view.py +++ b/dbt/adapters/bigquery/relation_configs/materialized_view.py @@ -3,6 +3,7 @@ import agate from dbt.exceptions import DbtRuntimeError +from dbt.adapters.relation_configs.config_change import RelationConfigChange from dbt.adapters.relation_configs.config_base import RelationResults from dbt.adapters.relation_configs.config_validation import RelationConfigValidationMixin from dbt.contracts.graph.nodes import ModelNode @@ -146,12 +147,55 @@ def parse_relation_results(cls, relation_results: RelationResults) -> dict: return config_dict +@dataclass(frozen=True, eq=True, unsafe_hash=True) +class BigQueryAutoRefreshConfigChange(RelationConfigChange): + context: Optional[bool] = None + + @property + def requires_full_refresh(self) -> bool: + return False + + +@dataclass(frozen=True, eq=True, unsafe_hash=True) +class BigQueryPartitionConfigChange(RelationConfigChange): + context: Optional[bool] = None + + @property + def requires_full_refresh(self) -> bool: + return True + + +@dataclass(frozen=True, eq=True, unsafe_hash=True) +class BigQueryClusterConfigChange(RelationConfigChange): + context: Optional[bool] = None + + @property + def requires_full_refresh(self) -> bool: + return True + + @dataclass class BigQueryMaterializedViewConfigChangeset: + partition_by: Optional[BigQueryPartitionConfigChange] = None + cluster_by: Optional[BigQueryClusterConfigChange] = None + auto_refresh: Optional[BigQueryAutoRefreshConfigChange] = None + @property def requires_full_refresh(self) -> bool: - return True + return any( + { + self.auto_refresh.requires_full_refresh if self.auto_refresh else False, + self.partition_by.requires_full_refresh if self.partition_by else False, + self.cluster_by.requires_full_refresh if self.cluster_by else False, + } + ) @property def has_changes(self) -> bool: - return True + return any( + { + self.partition_by if self.partition_by else False, + self.cluster_by if self.cluster_by else False, + self.auto_refresh if self.auto_refresh else False, + } + )