Skip to content

Commit 0c323d6

Browse files
authored
Chore!: bump sqlglot to v26.17.1 (#4338)
1 parent ab09f9b commit 0c323d6

4 files changed

Lines changed: 32 additions & 5 deletions

File tree

examples/sushi/models/marketing.sql

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,5 @@ FROM
2020
customer_id: 'int',
2121
status: 'text',
2222
updated_at: 'timestamp',
23-
valid_from: 'timestamp',
24-
valid_to: 'timestamp',
2523
}
2624
)

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ dependencies = [
2121
"requests",
2222
"rich[jupyter]",
2323
"ruamel.yaml",
24-
"sqlglot[rs]~=26.16.3",
24+
"sqlglot[rs]~=26.17.1",
2525
"tenacity",
2626
"time-machine",
2727
"json-stream"

tests/core/engine_adapter/integration/test_integration.py

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1446,6 +1446,35 @@ def test_sushi(ctx: TestContext, tmp_path_factory: pytest.TempPathFactory):
14461446
f"CREATE VIEW {raw_test_schema}.demographics ON CLUSTER cluster1 AS SELECT 1 AS customer_id, '00000' AS zip;"
14471447
)
14481448

1449+
# DuckDB parses TIMESTAMP into Type.TIMESTAMPNTZ which generates into TIMESTAMP_NTZ for
1450+
# Spark, but this type is not supported in Spark's DDL statements so we make it a TIMESTAMP
1451+
if ctx.dialect == "spark":
1452+
for model_key, model in context._models.items():
1453+
model_columns = model.columns_to_types
1454+
1455+
updated_model_columns = {}
1456+
for k, v in model_columns.items():
1457+
updated_model_columns[k] = v
1458+
if v.this == exp.DataType.Type.TIMESTAMPNTZ:
1459+
v.set("this", exp.DataType.Type.TIMESTAMP)
1460+
1461+
update_fields = {
1462+
"columns_to_types": updated_model_columns,
1463+
"columns_to_types_": updated_model_columns,
1464+
"columns_to_types_or_raise": updated_model_columns,
1465+
}
1466+
1467+
# We get rid of the sushi.marketing post statement here because it asserts that
1468+
# updated_at is a 'timestamp', which is parsed using duckdb in assert_has_columns
1469+
# and the assertion fails because we now have TIMESTAMPs and not TIMESTAMPNTZs in
1470+
# the columns_to_types mapping
1471+
if '"marketing"' in model_key:
1472+
update_fields["post_statements_"] = []
1473+
1474+
context._models.update(
1475+
{model_key: context._models[model_key].copy(update=update_fields)}
1476+
)
1477+
14491478
if ctx.dialect == "athena":
14501479
for model_name in {"customer_revenue_lifetime"}:
14511480
model_key = next(k for k in context._models if model_name in k)

tests/core/test_model.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -250,15 +250,15 @@ def test_model_union_query(sushi_context, assert_exp_eq):
250250
"""SELECT
251251
CAST("marketing"."customer_id" AS INT) AS "customer_id",
252252
CAST("marketing"."status" AS TEXT) AS "status",
253-
CAST("marketing"."updated_at" AS TIMESTAMP) AS "updated_at",
253+
CAST("marketing"."updated_at" AS TIMESTAMPNTZ) AS "updated_at",
254254
CAST("marketing"."valid_from" AS TIMESTAMP) AS "valid_from",
255255
CAST("marketing"."valid_to" AS TIMESTAMP) AS "valid_to"
256256
FROM "memory"."sushi"."marketing" AS "marketing"
257257
UNION ALL
258258
SELECT
259259
CAST("marketing"."customer_id" AS INT) AS "customer_id",
260260
CAST("marketing"."status" AS TEXT) AS "status",
261-
CAST("marketing"."updated_at" AS TIMESTAMP) AS "updated_at",
261+
CAST("marketing"."updated_at" AS TIMESTAMPNTZ) AS "updated_at",
262262
CAST("marketing"."valid_from" AS TIMESTAMP) AS "valid_from",
263263
CAST("marketing"."valid_to" AS TIMESTAMP) AS "valid_to"
264264
FROM "memory"."sushi"."marketing" AS "marketing"

0 commit comments

Comments
 (0)