Skip to content

Commit 4b3fc1e

Browse files
Fixed Casing Issue In Snapshot Target Validation (#1101)
1 parent b58d44b commit 4b3fc1e

File tree

4 files changed

+32
-20
lines changed

4 files changed

+32
-20
lines changed
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
kind: Fixes
2+
body: Fix casing issue in snapshot target validation.
3+
time: 2025-05-15T16:58:40.291931-04:00
4+
custom:
5+
Author: peterallenwebb
6+
Issue: "1101"

dbt-adapters/src/dbt/adapters/base/impl.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -872,7 +872,7 @@ def valid_snapshot_target(
872872
# aren't always present.
873873
for column in ("dbt_scd_id", "dbt_valid_from", "dbt_valid_to"):
874874
desired = column_names[column] if column_names else column
875-
if desired not in names:
875+
if desired and desired.lower() not in names:
876876
missing.append(desired)
877877

878878
if missing:
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
kind: Fixes
2+
body: Modify tests to exercise case differences in snapshot target meta columns.
3+
time: 2025-05-15T17:33:20.926659-04:00
4+
custom:
5+
Author: peterallenwebb
6+
Issue: "1101"

dbt-tests-adapter/src/dbt/tests/adapter/simple_snapshot/fixtures.py

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
-- snapshotting fields
2323
updated_at TIMESTAMP,
2424
test_valid_from TIMESTAMP,
25-
test_valid_to TIMESTAMP,
25+
TEST_VAILD_TO TIMESTAMP,
2626
test_scd_id TEXT,
2727
test_updated_at TIMESTAMP
2828
);
@@ -68,7 +68,7 @@
6868
ip_address,
6969
updated_at,
7070
test_valid_from,
71-
test_valid_to,
71+
TEST_VALID_TO,
7272
test_updated_at,
7373
test_scd_id
7474
)
@@ -83,7 +83,7 @@
8383
updated_at,
8484
-- fields added by snapshotting
8585
updated_at as test_valid_from,
86-
null::timestamp as test_valid_to,
86+
null::timestamp as TEST_VALID_TO,
8787
updated_at as test_updated_at,
8888
md5(id || '-' || first_name || '|' || updated_at::text) as test_scd_id
8989
from {schema}.seed;
@@ -100,7 +100,7 @@
100100
ip_address,
101101
updated_at,
102102
test_valid_from,
103-
test_valid_to,
103+
TEST_VAILD_TO,
104104
test_updated_at,
105105
test_scd_id
106106
)
@@ -115,7 +115,7 @@
115115
updated_at,
116116
-- fields added by snapshotting
117117
updated_at as test_valid_from,
118-
date('2099-12-31') as test_valid_to,
118+
date('2099-12-31') as TEST_VALID_TO,
119119
updated_at as test_updated_at,
120120
md5(id || '-' || first_name || '|' || updated_at::text) as test_scd_id
121121
from {schema}.seed;
@@ -142,7 +142,7 @@
142142
strategy: timestamp
143143
updated_at: updated_at
144144
snapshot_meta_column_names:
145-
dbt_valid_to: test_valid_to
145+
dbt_valid_to: TEST_VALID_TO
146146
dbt_valid_from: test_valid_from
147147
dbt_scd_id: test_scd_id
148148
dbt_updated_at: test_updated_at
@@ -171,7 +171,7 @@
171171
172172
-- invalidate records 11 - 21
173173
update {schema}.snapshot_expected set
174-
test_valid_to = updated_at + interval '1 hour'
174+
TEST_VALID_TO = updated_at + interval '1 hour'
175175
where id >= 10 and id <= 20;
176176
177177
"""
@@ -188,7 +188,7 @@
188188
ip_address,
189189
updated_at,
190190
test_valid_from,
191-
test_valid_to,
191+
TEST_VALID_TO,
192192
test_updated_at,
193193
test_scd_id
194194
)
@@ -203,7 +203,7 @@
203203
updated_at,
204204
-- fields added by snapshotting
205205
updated_at as test_valid_from,
206-
null::timestamp as test_valid_to,
206+
null::timestamp as TEST_VALID_TO,
207207
updated_at as test_updated_at,
208208
md5(id || '-' || first_name || '|' || updated_at::text) as test_scd_id
209209
from {schema}.seed
@@ -220,7 +220,7 @@
220220
updated_at: updated_at
221221
dbt_valid_to_current: "date('2099-12-31')"
222222
snapshot_meta_column_names:
223-
dbt_valid_to: test_valid_to
223+
dbt_valid_to: TEST_VALID_TO
224224
dbt_valid_from: test_valid_from
225225
dbt_scd_id: test_scd_id
226226
dbt_updated_at: test_updated_at
@@ -238,7 +238,7 @@
238238
ip_address,
239239
updated_at,
240240
test_valid_from,
241-
test_valid_to,
241+
TEST_VALID_TO,
242242
test_updated_at,
243243
test_scd_id
244244
)
@@ -253,7 +253,7 @@
253253
updated_at,
254254
-- fields added by snapshotting
255255
updated_at as test_valid_from,
256-
date('2099-12-31') as test_valid_to,
256+
date('2099-12-31') as TEST_VALID_TO,
257257
updated_at as test_updated_at,
258258
md5(id || '-' || first_name || '|' || updated_at::text) as test_scd_id
259259
from {schema}.seed
@@ -290,7 +290,7 @@
290290
-- snapshotting fields
291291
updated_at TIMESTAMP,
292292
test_valid_from TIMESTAMP,
293-
test_valid_to TIMESTAMP,
293+
TEST_VALID_TO TIMESTAMP,
294294
test_scd_id TEXT,
295295
test_updated_at TIMESTAMP
296296
);
@@ -335,7 +335,7 @@
335335
ip_address,
336336
updated_at,
337337
test_valid_from,
338-
test_valid_to,
338+
TEST_VALID_TO,
339339
test_updated_at,
340340
test_scd_id
341341
)
@@ -351,7 +351,7 @@
351351
updated_at,
352352
-- fields added by snapshotting
353353
updated_at as test_valid_from,
354-
null::timestamp as test_valid_to,
354+
null::timestamp as TEST_VALID_TO,
355355
updated_at as test_updated_at,
356356
md5(id1::text || '|' || id2::text || '|' || updated_at::text) as test_scd_id
357357
from {schema}.seed;
@@ -372,7 +372,7 @@
372372
- id1
373373
- id2
374374
snapshot_meta_column_names:
375-
dbt_valid_to: test_valid_to
375+
dbt_valid_to: TEST_VALID_TO
376376
dbt_valid_from: test_valid_from
377377
dbt_scd_id: test_scd_id
378378
dbt_updated_at: test_updated_at
@@ -388,7 +388,7 @@
388388
389389
-- invalidate records 11 - 21
390390
update {schema}.snapshot_expected set
391-
test_valid_to = updated_at + interval '1 hour'
391+
TEST_VALID_TO = updated_at + interval '1 hour'
392392
where id1 >= 10 and id1 <= 20;
393393
394394
"""
@@ -406,7 +406,7 @@
406406
ip_address,
407407
updated_at,
408408
test_valid_from,
409-
test_valid_to,
409+
TEST_VALID_TO,
410410
test_updated_at,
411411
test_scd_id
412412
)
@@ -422,7 +422,7 @@
422422
updated_at,
423423
-- fields added by snapshotting
424424
updated_at as test_valid_from,
425-
null::timestamp as test_valid_to,
425+
null::timestamp as TEST_VALID_TO,
426426
updated_at as test_updated_at,
427427
md5(id1::text || '|' || id2::text || '|' || updated_at::text) as test_scd_id
428428
from {schema}.seed

0 commit comments

Comments
 (0)