Skip to content

Commit 003593b

Browse files
committed
test(db2): handle TIMESTAMPTZ in test_to_time_column (SQL0180N)
Db2 has no native timezone-aware TIMESTAMP type — TIMESTAMPTZ is mapped to TIMESTAMP by db2_sqlglot. CAST('2020-01-01 00:00:00+00:00' AS TIMESTAMP) is rejected with SQL0180N because Db2 TIMESTAMP literals do not accept a UTC offset suffix (+00:00). Fix mirrors the existing Clickhouse guard: - Strip the +XX:XX offset from the string before calling to_time_column - Downcast the type to plain TIMESTAMP so to_time_column uses to_ts() - Add db2 to the TIMESTAMPTZ result dict with no-tz value (same as mysql/fabric/spark, which also lack native timezone-aware types)
1 parent d36f6b3 commit 003593b

1 file changed

Lines changed: 9 additions & 0 deletions

File tree

tests/core/engine_adapter/integration/test_integration.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2680,6 +2680,7 @@ def test_dialects(ctx: TestContext):
26802680
{
26812681
"default": pd.Timestamp("2020-01-01 00:00:00+00:00"),
26822682
"clickhouse": pd.Timestamp("2020-01-01 00:00:00"),
2683+
"db2": pd.Timestamp("2020-01-01 00:00:00"),
26832684
"fabric": pd.Timestamp("2020-01-01 00:00:00"),
26842685
"mysql": pd.Timestamp("2020-01-01 00:00:00"),
26852686
"spark": pd.Timestamp("2020-01-01 00:00:00"),
@@ -2723,6 +2724,14 @@ def test_to_time_column(
27232724
time_column = re.match(r"^(.*?)\+", time_column).group(1)
27242725
time_column_type = exp.DataType.build("TIMESTAMP('UTC')", dialect="clickhouse")
27252726

2727+
if ctx.dialect == "db2" and time_column_type.is_type(exp.DataType.Type.TIMESTAMPTZ):
2728+
# Db2 has no native timezone-aware TIMESTAMP type (TIMESTAMPTZ maps to TIMESTAMP).
2729+
# CAST('2020-01-01 00:00:00+00:00' AS TIMESTAMP) is rejected with SQL0180N because
2730+
# Db2's TIMESTAMP literal format does not accept a UTC offset suffix.
2731+
# Strip the timezone offset and downcast to plain TIMESTAMP, same approach as Clickhouse.
2732+
time_column = re.match(r"^(.*?)\+", time_column).group(1)
2733+
time_column_type = exp.DataType.build("TIMESTAMP")
2734+
27262735
time_column = to_time_column(time_column, time_column_type, ctx.dialect, time_column_format)
27272736
df = ctx.engine_adapter.fetchdf(exp.select(time_column).as_("the_col"))
27282737
expected = result.get(ctx.dialect, result.get("default"))

0 commit comments

Comments
 (0)