diff --git a/core/dbt/adapters/base/relation.py b/core/dbt/adapters/base/relation.py index 5db65d5495d..9cb4d733676 100644 --- a/core/dbt/adapters/base/relation.py +++ b/core/dbt/adapters/base/relation.py @@ -36,7 +36,10 @@ class BaseRelation(FakeAPIObject, Hashable): include_policy: Policy = field(default_factory=lambda: Policy()) quote_policy: Policy = field(default_factory=lambda: Policy()) dbt_created: bool = False - relations_that_can_be_renamed: List[StrEnum] = field(default_factory=list) + # register relation types that can be renamed for the purpose of replacing relations using stages and backups + renameable_relations: List[StrEnum] = field( + default_factory=lambda: [RelationType.Table, RelationType.View] + ) def _is_exactish_match(self, field: ComponentName, value: str) -> bool: if self.dbt_created and self.quote_policy.get_part(field) is False: @@ -289,7 +292,7 @@ def create( @property def can_be_renamed(self): - return self.type in self.relations_that_can_be_renamed + return self.type in self.renameable_relations def __repr__(self) -> str: return "<{} {}>".format(self.__class__.__name__, self.render()) diff --git a/tests/unit/test_relation.py b/tests/unit/test_relation.py index 3e0ebf7fac8..f67c8744817 100644 --- a/tests/unit/test_relation.py +++ b/tests/unit/test_relation.py @@ -15,5 +15,5 @@ ) def test_can_be_renamed(relation_type, result): my_relation = BaseRelation.create(type=relation_type) - my_relation = replace(my_relation, relations_that_can_be_renamed=[RelationType.View]) + my_relation = replace(my_relation, renameable_relations=[RelationType.View]) assert my_relation.can_be_renamed is result