Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix the renamed relations code #723

Merged
merged 10 commits into from
Mar 21, 2024
6 changes: 6 additions & 0 deletions .changes/unreleased/Under the Hood-20240227-002713.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
kind: Under the Hood
body: Add unit test for transaction semantics.
time: 2024-02-27T00:27:13.299107-08:00
custom:
Author: versusfacit
Issue: "722"
26 changes: 15 additions & 11 deletions dbt/adapters/redshift/relation.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from dataclasses import dataclass
from dataclasses import dataclass, field
from dbt.adapters.contracts.relation import RelationConfig
from typing import Optional
from typing import FrozenSet, Optional

from dbt.adapters.base.relation import BaseRelation
from dbt.adapters.relation_configs import (
Expand Down Expand Up @@ -30,16 +30,20 @@ class RedshiftRelation(BaseRelation):
relation_configs = {
RelationType.MaterializedView.value: RedshiftMaterializedViewConfig,
}
renameable_relations = frozenset(
{
RelationType.View,
RelationType.Table,
}
renameable_relations: FrozenSet[RelationType] = field(
default_factory=lambda: frozenset(
{
RelationType.View,
RelationType.Table,
}
)
)
replaceable_relations = frozenset(
{
RelationType.View,
}
replaceable_relations: FrozenSet[RelationType] = field(
default_factory=lambda: frozenset(
{
RelationType.View,
}
)
)

def __post_init__(self):
Expand Down
2 changes: 1 addition & 1 deletion dev-requirements.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# install latest changes in dbt-core + dbt-postgres
git+https://github.com/dbt-labs/dbt-adapters.git
mikealfare marked this conversation as resolved.
Show resolved Hide resolved
git+https://github.com/dbt-labs/dbt-adapters.git#subdirectory=dbt-tests-adapter
git+https://github.com/dbt-labs/dbt-adapters.git@ADAP-108/fix_renamed_relations_for_1.8#subdirectory=dbt-tests-adapter
git+https://github.com/dbt-labs/dbt-common.git
git+https://github.com/dbt-labs/dbt-core.git#subdirectory=core
git+https://github.com/dbt-labs/dbt-postgres.git
Expand Down
17 changes: 17 additions & 0 deletions tests/unit/test_renamed_relations.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
from dbt.adapters.redshift.relation import RedshiftRelation
from dbt.adapters.contracts.relation import RelationType


def test_renameable_relation():
relation = RedshiftRelation.create(
database="my_db",
schema="my_schema",
identifier="my_table",
type=RelationType.Table,
)
assert relation.renameable_relations == frozenset(
{
RelationType.View,
RelationType.Table,
}
)
Loading