Skip to content

Commit

Permalink
fix(mysql): explicitly handle the zero integer -> timestamp case
Browse files Browse the repository at this point in the history
  • Loading branch information
cpcloud committed Feb 18, 2025
1 parent 90a1aee commit f5e8c4f
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion ibis/backends/sql/compilers/mysql.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,11 @@ def visit_Cast(self, op, *, arg, to):
# for TEXT (except when casting of course!)
return arg
elif from_.is_integer() and to.is_timestamp():
return self.f.from_unixtime(arg)
return self.if_(
arg.eq(0),
self.f.timestamp("1970-01-01 00:00:00"),
self.f.from_unixtime(arg),
)
return super().visit_Cast(op, arg=arg, to=to)

def visit_TimestampDiff(self, op, *, left, right):
Expand Down

0 comments on commit f5e8c4f

Please sign in to comment.