From 5d8866a36ac8055a93d0643bd697993fb4129629 Mon Sep 17 00:00:00 2001 From: Phillip Cloud <417981+cpcloud@users.noreply.github.com> Date: Tue, 12 Dec 2023 13:29:02 -0500 Subject: [PATCH] fix(duckdb): render dates, times, timestamps and none literals correctly --- ibis/backends/duckdb/registry.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/ibis/backends/duckdb/registry.py b/ibis/backends/duckdb/registry.py index f91fa4ce8ceb..126bd417619a 100644 --- a/ibis/backends/duckdb/registry.py +++ b/ibis/backends/duckdb/registry.py @@ -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) @@ -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():