Skip to content

Commit

Permalink
Add test and move semantics. (#913) (#946)
Browse files Browse the repository at this point in the history
* Add test and move semantics
* Add FrozenSet to imports
* Tweak test failures
* remove extra semicolon

---------

Co-authored-by: Mila Page <[email protected]>
Co-authored-by: Mike Alfare <[email protected]>
Co-authored-by: Mike Alfare <[email protected]>
(cherry picked from commit 73b6a12)

Co-authored-by: Mila Page <[email protected]>
Co-authored-by: Mike Alfare <[email protected]>
  • Loading branch information
3 people authored Mar 21, 2024
1 parent b532809 commit bdc975e
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-010428.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-27T01:04:28.713433-08:00
custom:
Author: versusfacit
Issue: "912"
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
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,5 @@
as (
{{ sql }}
)
;

{%- endmacro %}
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.snowflake.relation import SnowflakeRelation
from dbt.adapters.snowflake.relation_configs import SnowflakeRelationType


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

0 comments on commit bdc975e

Please sign in to comment.