Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ dependencies = [
"requests",
"rich[jupyter]",
"ruamel.yaml",
"sqlglot[rs]~=28.6.0",
"sqlglot[rs]~=28.7.0",
"tenacity",
"time-machine",
"json-stream"
Expand Down
2 changes: 1 addition & 1 deletion sqlmesh/core/state_sync/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ def all_batch_range(cls) -> ExpiredBatchRange:
def _expanded_tuple_comparison(
cls,
columns: t.List[exp.Column],
values: t.List[exp.Literal],
values: t.List[t.Union[exp.Literal, exp.Neg]],
operator: t.Type[exp.Expression],
) -> exp.Expression:
"""Generate expanded tuple comparison that works across all SQL engines.
Expand Down
10 changes: 6 additions & 4 deletions tests/core/test_snapshot_evaluator.py
Original file line number Diff line number Diff line change
Expand Up @@ -2131,7 +2131,7 @@ def test_temp_table_includes_schema_for_ignore_changes(
model = SqlModel(
name="test_schema.test_model",
kind=IncrementalByTimeRangeKind(
time_column="a", on_destructive_change=OnDestructiveChange.IGNORE
time_column="ds", on_destructive_change=OnDestructiveChange.IGNORE
),
query=parse_one("SELECT c, a FROM tbl WHERE ds BETWEEN @start_ds and @end_ds"),
)
Expand All @@ -2148,6 +2148,7 @@ def columns(table_name):
return {
"c": exp.DataType.build("int"),
"a": exp.DataType.build("int"),
"ds": exp.DataType.build("timestamp"),
}

adapter.columns = columns # type: ignore
Expand Down Expand Up @@ -4321,13 +4322,14 @@ def test_multiple_engine_promotion(mocker: MockerFixture, adapter_mock, make_sna
def columns(table_name):
return {
"a": exp.DataType.build("int"),
"ds": exp.DataType.build("timestamp"),
}

adapter.columns = columns # type: ignore

model = SqlModel(
name="test_schema.test_model",
kind=IncrementalByTimeRangeKind(time_column="a"),
kind=IncrementalByTimeRangeKind(time_column="ds"),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lg, thanks for fixing

gateway="secondary",
query=parse_one("SELECT a FROM tbl WHERE ds BETWEEN @start_ds and @end_ds"),
)
Expand All @@ -4350,10 +4352,10 @@ def columns(table_name):
cursor_mock.execute.assert_has_calls(
[
call(
f'DELETE FROM "sqlmesh__test_schema"."test_schema__test_model__{snapshot.version}" WHERE "a" BETWEEN 2020-01-01 00:00:00+00:00 AND 2020-01-02 23:59:59.999999+00:00'
f'DELETE FROM "sqlmesh__test_schema"."test_schema__test_model__{snapshot.version}" WHERE "ds" BETWEEN CAST(\'2020-01-01 00:00:00\' AS TIMESTAMP) AND CAST(\'2020-01-02 23:59:59.999999\' AS TIMESTAMP)'
),
call(
f'INSERT INTO "sqlmesh__test_schema"."test_schema__test_model__{snapshot.version}" ("a") SELECT "a" FROM (SELECT "a" AS "a" FROM "tbl" AS "tbl" WHERE "ds" BETWEEN \'2020-01-01\' AND \'2020-01-02\') AS "_subquery" WHERE "a" BETWEEN 2020-01-01 00:00:00+00:00 AND 2020-01-02 23:59:59.999999+00:00'
f'INSERT INTO "sqlmesh__test_schema"."test_schema__test_model__{snapshot.version}" ("a", "ds") SELECT "a", "ds" FROM (SELECT "a" AS "a" FROM "tbl" AS "tbl" WHERE "ds" BETWEEN \'2020-01-01\' AND \'2020-01-02\') AS "_subquery" WHERE "ds" BETWEEN CAST(\'2020-01-01 00:00:00\' AS TIMESTAMP) AND CAST(\'2020-01-02 23:59:59.999999\' AS TIMESTAMP)'
),
]
)
Expand Down