From 59cb168bbb0f7b01591016ab64f3fa1f2f3716cd Mon Sep 17 00:00:00 2001 From: Mila Page <67295367+VersusFacit@users.noreply.github.com> Date: Thu, 21 Mar 2024 07:24:47 -0700 Subject: [PATCH] Adap 108/fix renamed relations for 1.8 (#109) Co-authored-by: Mila Page Co-authored-by: Mike Alfare <13974384+mikealfare@users.noreply.github.com> Co-authored-by: Mike Alfare --- .changes/unreleased/Fixes-20240226-224046.yaml | 6 ++++++ dbt/adapters/base/relation.py | 4 ++-- .../macros/relations/materialized_view/drop.sql | 2 +- dbt/include/global_project/macros/relations/table/drop.sql | 2 +- dbt/include/global_project/macros/relations/view/drop.sql | 2 +- 5 files changed, 11 insertions(+), 5 deletions(-) create mode 100644 .changes/unreleased/Fixes-20240226-224046.yaml diff --git a/.changes/unreleased/Fixes-20240226-224046.yaml b/.changes/unreleased/Fixes-20240226-224046.yaml new file mode 100644 index 00000000..d8e4b35b --- /dev/null +++ b/.changes/unreleased/Fixes-20240226-224046.yaml @@ -0,0 +1,6 @@ +kind: Fixes +body: Add field wrapper to BaseRelation members that were missing it. +time: 2024-02-26T22:40:46.271694-08:00 +custom: + Author: versusfacit + Issue: "108" diff --git a/dbt/adapters/base/relation.py b/dbt/adapters/base/relation.py index ea03b067..d74b29bd 100644 --- a/dbt/adapters/base/relation.py +++ b/dbt/adapters/base/relation.py @@ -52,13 +52,13 @@ class BaseRelation(FakeAPIObject, Hashable): # adding a relation type here also requires defining the associated rename macro # e.g. adding RelationType.View in dbt-postgres requires that you define: # include/postgres/macros/relations/view/rename.sql::postgres__get_rename_view_sql() - renameable_relations: SerializableIterable = () + renameable_relations: SerializableIterable = field(default_factory=frozenset) # register relation types that are atomically replaceable, e.g. they have "create or replace" syntax # adding a relation type here also requires defining the associated replace macro # e.g. adding RelationType.View in dbt-postgres requires that you define: # include/postgres/macros/relations/view/replace.sql::postgres__get_replace_view_sql() - replaceable_relations: SerializableIterable = () + replaceable_relations: SerializableIterable = field(default_factory=frozenset) def _is_exactish_match(self, field: ComponentName, value: str) -> bool: if self.dbt_created and self.quote_policy.get_part(field) is False: diff --git a/dbt/include/global_project/macros/relations/materialized_view/drop.sql b/dbt/include/global_project/macros/relations/materialized_view/drop.sql index e60e1dc2..b218d0f3 100644 --- a/dbt/include/global_project/macros/relations/materialized_view/drop.sql +++ b/dbt/include/global_project/macros/relations/materialized_view/drop.sql @@ -5,7 +5,7 @@ actually executes the drop, and `get_drop_sql`, which returns the template. */ #} {% macro drop_materialized_view(relation) -%} - {{ return(adapter.dispatch('drop_materialized_view', 'dbt')(relation)) }} + {{- adapter.dispatch('drop_materialized_view', 'dbt')(relation) -}} {%- endmacro %} diff --git a/dbt/include/global_project/macros/relations/table/drop.sql b/dbt/include/global_project/macros/relations/table/drop.sql index 359bab66..d7d5941c 100644 --- a/dbt/include/global_project/macros/relations/table/drop.sql +++ b/dbt/include/global_project/macros/relations/table/drop.sql @@ -5,7 +5,7 @@ actually executes the drop, and `get_drop_sql`, which returns the template. */ #} {% macro drop_table(relation) -%} - {{ return(adapter.dispatch('drop_table', 'dbt')(relation)) }} + {{- adapter.dispatch('drop_table', 'dbt')(relation) -}} {%- endmacro %} diff --git a/dbt/include/global_project/macros/relations/view/drop.sql b/dbt/include/global_project/macros/relations/view/drop.sql index c905f8da..7e1924fa 100644 --- a/dbt/include/global_project/macros/relations/view/drop.sql +++ b/dbt/include/global_project/macros/relations/view/drop.sql @@ -5,7 +5,7 @@ actually executes the drop, and `get_drop_sql`, which returns the template. */ #} {% macro drop_view(relation) -%} - {{ return(adapter.dispatch('drop_view', 'dbt')(relation)) }} + {{- adapter.dispatch('drop_view', 'dbt')(relation) -}} {%- endmacro %}