From 97332e6c5451d5c35ca1dbab5c1fd5ad02ac6bc9 Mon Sep 17 00:00:00 2001 From: Brett Naul Date: Thu, 9 Nov 2023 20:33:32 -0500 Subject: [PATCH] Recreate if allow_non_incremental_definition changed --- dbt/adapters/bigquery/relation.py | 10 +++++++++- dbt/adapters/bigquery/relation_configs/_options.py | 3 ++- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/dbt/adapters/bigquery/relation.py b/dbt/adapters/bigquery/relation.py index c14dba238..c4977be8d 100644 --- a/dbt/adapters/bigquery/relation.py +++ b/dbt/adapters/bigquery/relation.py @@ -78,8 +78,16 @@ def materialized_view_config_changeset( new_materialized_view = cls.materialized_view_from_model_node(runtime_config.model) if new_materialized_view.options != existing_materialized_view.options: + # allow_non_incremental_definition cannot be changed via ALTER, must recreate + if ( + new_materialized_view.options.allow_non_incremental_definition + == existing_materialized_view.options.allow_non_incremental_definition + ): + action = RelationConfigChangeAction.alter + else: + action = RelationConfigChangeAction.create config_change_collection.options = BigQueryOptionsConfigChange( - action=RelationConfigChangeAction.alter, + action=action, context=new_materialized_view.options, ) diff --git a/dbt/adapters/bigquery/relation_configs/_options.py b/dbt/adapters/bigquery/relation_configs/_options.py index e7a434da7..a36babcf2 100644 --- a/dbt/adapters/bigquery/relation_configs/_options.py +++ b/dbt/adapters/bigquery/relation_configs/_options.py @@ -8,6 +8,7 @@ from dbt.adapters.bigquery.relation_configs._base import BigQueryBaseRelationConfig from dbt.adapters.bigquery.utility import bool_setting, float_setting, sql_escape +from dbt.adapters.relation_configs import RelationConfigChangeAction @dataclass(frozen=True, eq=True, unsafe_hash=True) @@ -160,4 +161,4 @@ class BigQueryOptionsConfigChange(RelationConfigChange): @property def requires_full_refresh(self) -> bool: - return False + return self.action != RelationConfigChangeAction.alter