Skip to content

Commit 72e970b

Browse files
committed
Fixed test cases for snapshot unique_key
1 parent 45e9ac4 commit 72e970b

File tree

4 files changed

+63
-7
lines changed

4 files changed

+63
-7
lines changed

dbt_adbs_test_project/models/promotion_costs.sql

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
See the License for the specific language governing permissions and
1414
limitations under the License.
1515
#}
16-
{{ config(materialized='table', grants = {'select': ['dbt_test_1']})}}
16+
{{ config(materialized='table', grants = {'select': ['DBT_TEST_USER_1']})}}
1717
with all_promo_costs as(
1818
select * from {{ source('sh_database', 'promotions') }}
1919
)

tests/functional/adapter/snapshots/test_invalidate_deletes.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
"""
2-
Copyright (c) 2022, Oracle and/or its affiliates.
2+
Copyright (c) 2025, Oracle and/or its affiliates.
33
Copyright (c) 2020, Vitor Avancini
44
55
Licensed under the Apache License, Version 2.0 (the "License");
@@ -34,7 +34,7 @@
3434
{% snapshot cc_all_snapshot %}
3535
{{ config(
3636
check_cols='all',
37-
unique_key='id',
37+
unique_key=['id'],
3838
strategy='check',
3939
target_database=database,
4040
target_schema=schema,

tests/functional/adapter/test_basic.py

+58-2
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,50 @@
103103
"""
104104

105105

106+
cc_all_snapshot_sql = """
107+
{% snapshot cc_all_snapshot %}
108+
{{ config(
109+
check_cols='all', unique_key=['id'], strategy='check',
110+
target_database=database, target_schema=schema
111+
) }}
112+
select * from {{ ref(var('seed_name', 'base')) }}
113+
{% endsnapshot %}
114+
""".strip()
115+
116+
cc_name_snapshot_sql = """
117+
{% snapshot cc_name_snapshot %}
118+
{{ config(
119+
check_cols=['name'], unique_key=['id'], strategy='check',
120+
target_database=database, target_schema=schema
121+
) }}
122+
select * from {{ ref(var('seed_name', 'base')) }}
123+
{% endsnapshot %}
124+
""".strip()
125+
126+
cc_date_snapshot_sql = """
127+
{% snapshot cc_date_snapshot %}
128+
{{ config(
129+
check_cols=['some_date'], unique_key=['id'], strategy='check',
130+
target_database=database, target_schema=schema
131+
) }}
132+
select * from {{ ref(var('seed_name', 'base')) }}
133+
{% endsnapshot %}
134+
""".strip()
135+
136+
ts_snapshot_sql = """
137+
{% snapshot ts_snapshot %}
138+
{{ config(
139+
strategy='timestamp',
140+
unique_key=['id'],
141+
updated_at='some_date',
142+
target_database=database,
143+
target_schema=schema,
144+
)}}
145+
select * from {{ ref(var('seed_name', 'base')) }}
146+
{% endsnapshot %}
147+
""".strip()
148+
149+
106150
class TestSimpleMaterializationsOracle(BaseSimpleMaterializations):
107151
pass
108152

@@ -146,11 +190,23 @@ class TestGenericTestsOracle(BaseGenericTests):
146190

147191

148192
class TestSnapshotCheckColsOracle(BaseSnapshotCheckCols):
149-
pass
193+
194+
@pytest.fixture(scope="class")
195+
def snapshots(self):
196+
return {
197+
"cc_all_snapshot.sql": cc_all_snapshot_sql,
198+
"cc_date_snapshot.sql": cc_date_snapshot_sql,
199+
"cc_name_snapshot.sql": cc_name_snapshot_sql,
200+
}
150201

151202

152203
class TestSnapshotTimestampOracle(BaseSnapshotTimestamp):
153-
pass
204+
205+
@pytest.fixture(scope="class")
206+
def snapshots(self):
207+
return {
208+
"ts_snapshot.sql": ts_snapshot_sql,
209+
}
154210

155211

156212
class TestBaseAdapterMethodOracle(BaseAdapterMethod):

tests/functional/adapter/test_grants.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,10 @@
3838
my_snapshot_sql = """
3939
{% snapshot my_snapshot %}
4040
{{ config(
41-
check_cols='all', unique_key='id', strategy='check',
41+
check_cols='all', unique_key=['id'], strategy='check',
4242
target_database=database, target_schema=schema
4343
) }}
44-
select 1 as id, cast('blue' as {{ type_string() }}) as color from dual
44+
select 1 as id, cast('blue' as {{ type_string() }}) as color
4545
{% endsnapshot %}
4646
""".strip()
4747

0 commit comments

Comments
 (0)