Skip to content

Commit 2b81e68

Browse files
properly set null for all dialects
1 parent df91419 commit 2b81e68

File tree

2 files changed

+13
-9
lines changed

2 files changed

+13
-9
lines changed

sqlmesh/core/engine_adapter/base.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1773,7 +1773,11 @@ def remove_managed_columns(
17731773
if truncate
17741774
else exp.select(
17751775
*(
1776-
exp.Null().as_(col) if col == valid_to_col.name else exp.column(col)
1776+
to_time_column(
1777+
exp.null(), time_data_type, self.dialect, nullable=True
1778+
).as_(col)
1779+
if col == valid_to_col.name
1780+
else exp.column(col)
17771781
for col in columns_to_types
17781782
),
17791783
exp.true().as_("_exists"),
@@ -1783,7 +1787,7 @@ def remove_managed_columns(
17831787
exp.and_(
17841788
valid_from_col <= cleanup_ts,
17851789
exp.or_(
1786-
valid_to_col.is_(exp.Null()),
1790+
valid_to_col.is_(exp.null()),
17871791
valid_to_col >= cleanup_ts,
17881792
),
17891793
)

tests/core/engine_adapter/test_base.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1264,7 +1264,7 @@ def test_scd_type_2_by_time(make_mocked_engine_adapter: t.Callable):
12641264
"price",
12651265
"test_UPDATED_at",
12661266
"test_valid_from",
1267-
NULL AS "test_valid_to",
1267+
CAST(NULL AS TIMESTAMP) AS "test_valid_to",
12681268
TRUE AS "_exists"
12691269
FROM "target"
12701270
WHERE "test_valid_from" <= CAST('2020-01-01 00:00:00' AS TIMESTAMP)
@@ -1464,7 +1464,7 @@ def test_scd_type_2_by_time_no_invalidate_hard_deletes(make_mocked_engine_adapte
14641464
"price",
14651465
"test_updated_at",
14661466
"test_valid_from",
1467-
NULL AS "test_valid_to",
1467+
CAST(NULL AS TIMESTAMP) AS "test_valid_to",
14681468
TRUE AS "_exists"
14691469
FROM "target"
14701470
WHERE "test_valid_from" <= CAST('2020-01-01 00:00:00' AS TIMESTAMP)
@@ -1661,7 +1661,7 @@ def test_merge_scd_type_2_pandas(make_mocked_engine_adapter: t.Callable):
16611661
"price",
16621662
"test_updated_at",
16631663
"test_valid_from",
1664-
NULL AS "test_valid_to",
1664+
CAST(NULL AS TIMESTAMPTZ) AS "test_valid_to",
16651665
TRUE AS "_exists"
16661666
FROM "target"
16671667
WHERE "test_valid_from" <= CAST('2020-01-01 00:00:00+00:00' AS TIMESTAMPTZ)
@@ -1839,7 +1839,7 @@ def test_scd_type_2_by_column(make_mocked_engine_adapter: t.Callable):
18391839
"name",
18401840
"price",
18411841
"test_VALID_from",
1842-
NULL AS "test_valid_to",
1842+
CAST(NULL AS TIMESTAMP) AS "test_valid_to",
18431843
TRUE AS "_exists"
18441844
FROM "target"
18451845
WHERE "test_VALID_from" <= CAST('2020-01-01 00:00:00' AS TIMESTAMP)
@@ -2034,7 +2034,7 @@ def test_scd_type_2_by_column_composite_key(make_mocked_engine_adapter: t.Callab
20342034
"name",
20352035
"price",
20362036
"test_VALID_from",
2037-
NULL AS "test_valid_to",
2037+
CAST(NULL AS TIMESTAMP) AS "test_valid_to",
20382038
TRUE AS "_exists"
20392039
FROM "target"
20402040
WHERE "test_VALID_from" <= CAST('2020-01-01 00:00:00' AS TIMESTAMP)
@@ -2394,7 +2394,7 @@ def test_scd_type_2_by_column_star_check(make_mocked_engine_adapter: t.Callable)
23942394
"name",
23952395
"price",
23962396
"test_valid_from",
2397-
NULL AS "test_valid_to",
2397+
CAST(NULL AS TIMESTAMP) AS "test_valid_to",
23982398
TRUE AS "_exists"
23992399
FROM "target"
24002400
WHERE "test_valid_from" <= CAST('2020-01-01 00:00:00' AS TIMESTAMP)
@@ -2570,7 +2570,7 @@ def test_scd_type_2_by_column_no_invalidate_hard_deletes(make_mocked_engine_adap
25702570
"name",
25712571
"price",
25722572
"test_valid_from",
2573-
NULL AS "test_valid_to",
2573+
CAST(NULL AS TIMESTAMP) AS "test_valid_to",
25742574
TRUE AS "_exists"
25752575
FROM "target"
25762576
WHERE "test_valid_from" <= CAST('2020-01-01 00:00:00' AS TIMESTAMP)

0 commit comments

Comments
 (0)