Skip to content

Commit

Permalink
fix(mysql): cast mysql timestamp literals to ensure correct return type
Browse files Browse the repository at this point in the history
  • Loading branch information
cpcloud committed Jul 7, 2022
1 parent 8ea4e3a commit 8116e04
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion ibis/backends/mysql/registry.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,14 @@

import ibis
import ibis.common.exceptions as com
import ibis.expr.datatypes as dt
import ibis.expr.operations as ops
import ibis.expr.types as ir
from ibis.backends.base.sql.alchemy import (
fixed_arity,
sqlalchemy_operation_registry,
sqlalchemy_window_functions_registry,
to_sqla_type,
unary,
)
from ibis.backends.base.sql.alchemy.registry import _gen_string_find
Expand Down Expand Up @@ -126,7 +128,11 @@ def _literal(_, expr):
value = expr.op().value
if isinstance(value, pd.Timestamp):
value = value.to_pydatetime()
return sa.literal(value)

lit = sa.literal(value)
if isinstance(dtype := expr.type(), dt.Timestamp):
return sa.cast(lit, to_sqla_type(dtype))
return lit


def _group_concat(t, expr):
Expand Down

0 comments on commit 8116e04

Please sign in to comment.