Skip to content

Commit

Permalink
Migrate 1.8 over
Browse files Browse the repository at this point in the history
  • Loading branch information
VersusFacit committed Feb 27, 2024
1 parent 03c276e commit 8d6c11d
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 9 deletions.
6 changes: 6 additions & 0 deletions .changes/unreleased/Under the Hood-20240227-020742.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-27T02:07:42.87704-08:00
custom:
Author: versusfacit
Issue: "914"
27 changes: 19 additions & 8 deletions dbt/adapters/snowflake/relation.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from dataclasses import dataclass, field
from typing import Optional, Type
from typing import FrozenSet, Optional, Type

from dbt.adapters.base.relation import BaseRelation
from dbt.adapters.relation_configs import RelationConfigChangeAction, RelationResults
Expand All @@ -20,13 +20,24 @@
class SnowflakeRelation(BaseRelation):
type: Optional[SnowflakeRelationType] = None # type: ignore
quote_policy: SnowflakeQuotePolicy = field(default_factory=lambda: SnowflakeQuotePolicy())
renameable_relations = frozenset({SnowflakeRelationType.Table, SnowflakeRelationType.View})
replaceable_relations = frozenset(
{
SnowflakeRelationType.DynamicTable,
SnowflakeRelationType.Table,
SnowflakeRelationType.View,
}

renameable_relations: FrozenSet[SnowflakeRelationType] = field(
default_factory=lambda: frozenset(
{
SnowflakeRelationType.Table,
SnowflakeRelationType.View,
}
)
)

replaceable_relations: FrozenSet[SnowflakeRelationType] = field(
default_factory=lambda: frozenset(
{
SnowflakeRelationType.DynamicTable,
SnowflakeRelationType.Table,
SnowflakeRelationType.View,
}
)
)

@property
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
# TODO: how to automate switching from develop to version branches?
git+https://github.com/dbt-labs/dbt-core.git@1.7.latest#egg=dbt-core&subdirectory=core
git+https://github.com/dbt-labs/dbt-core.git@ADAP-9681/fix_renamed_relations_override_pre_1.8#egg=dbt-core&subdirectory=core
git+https://github.com/dbt-labs/[email protected]#egg=dbt-tests-adapter&subdirectory=tests/adapter

# if version 1.x or greater -> pin to major version
Expand Down
16 changes: 16 additions & 0 deletions tests/unit/test_renamed_relations.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
from dbt.adapters.bigquery.relation import BigQueryRelation
from dbt.adapters.contracts.relation import RelationType


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

0 comments on commit 8d6c11d

Please sign in to comment.