Skip to content

Commit 265376f

Browse files
authored
refactor: fix test_dt_tz_localize in the sqlglot compiler (#2517)
1 parent 2326ad6 commit 265376f

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

bigframes/core/compile/sqlglot/expressions/datetime_ops.py

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -371,7 +371,12 @@ def _(expr: TypedExpr, op: ops.ToDatetimeOp) -> sge.Expression:
371371
)
372372
return sge.Cast(this=result, to="DATETIME")
373373

374-
if expr.dtype in (dtypes.STRING_DTYPE, dtypes.TIMESTAMP_DTYPE):
374+
if expr.dtype in (
375+
dtypes.STRING_DTYPE,
376+
dtypes.TIMESTAMP_DTYPE,
377+
dtypes.DATETIME_DTYPE,
378+
dtypes.DATE_DTYPE,
379+
):
375380
return sge.TryCast(this=expr.expr, to="DATETIME")
376381

377382
value = expr.expr
@@ -396,7 +401,12 @@ def _(expr: TypedExpr, op: ops.ToTimestampOp) -> sge.Expression:
396401
"PARSE_TIMESTAMP", sge.convert(op.format), expr.expr, sge.convert("UTC")
397402
)
398403

399-
if expr.dtype in (dtypes.STRING_DTYPE, dtypes.DATETIME_DTYPE):
404+
if expr.dtype in (
405+
dtypes.STRING_DTYPE,
406+
dtypes.DATETIME_DTYPE,
407+
dtypes.TIMESTAMP_DTYPE,
408+
dtypes.DATE_DTYPE,
409+
):
400410
return sge.func("TIMESTAMP", expr.expr)
401411

402412
value = expr.expr

0 commit comments

Comments
 (0)