Skip to content

Commit

Permalink
fix(duckdb): render dates, times, timestamps and none literals correctly
Browse files Browse the repository at this point in the history
  • Loading branch information
cpcloud authored and gforsyth committed Dec 12, 2023
1 parent 66fbad6 commit 5d8866a
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions ibis/backends/duckdb/registry.py
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,9 @@ def _literal(t, op):
value = op.value

if value is None:
return sa.null()
return (
sa.null() if dtype.is_null() else sa.cast(sa.null(), t.get_sqla_type(dtype))
)

sqla_type = t.get_sqla_type(dtype)

Expand Down Expand Up @@ -209,7 +211,7 @@ def _literal(t, op):
sa.func.list_value(*value.keys()), sa.func.list_value(*value.values())
)
elif dtype.is_timestamp():
return sa.cast(value.isoformat(), t.get_sqla_type(dtype))
return sa.cast(sa.literal(value.isoformat()), t.get_sqla_type(dtype))
elif dtype.is_date():
return sa.func.make_date(value.year, value.month, value.day)
elif dtype.is_time():
Expand Down

0 comments on commit 5d8866a

Please sign in to comment.