Skip to content

Commit 5d8866a

Browse files
cpcloudgforsyth
authored andcommitted
fix(duckdb): render dates, times, timestamps and none literals correctly
1 parent 66fbad6 commit 5d8866a

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

ibis/backends/duckdb/registry.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,9 @@ def _literal(t, op):
176176
value = op.value
177177

178178
if value is None:
179-
return sa.null()
179+
return (
180+
sa.null() if dtype.is_null() else sa.cast(sa.null(), t.get_sqla_type(dtype))
181+
)
180182

181183
sqla_type = t.get_sqla_type(dtype)
182184

@@ -209,7 +211,7 @@ def _literal(t, op):
209211
sa.func.list_value(*value.keys()), sa.func.list_value(*value.values())
210212
)
211213
elif dtype.is_timestamp():
212-
return sa.cast(value.isoformat(), t.get_sqla_type(dtype))
214+
return sa.cast(sa.literal(value.isoformat()), t.get_sqla_type(dtype))
213215
elif dtype.is_date():
214216
return sa.func.make_date(value.year, value.month, value.day)
215217
elif dtype.is_time():

0 commit comments

Comments
 (0)