From 33ec7547209cc7775f85bd46a30f971333ea35bb Mon Sep 17 00:00:00 2001 From: Phillip Cloud <417981+cpcloud@users.noreply.github.com> Date: Thu, 27 Jun 2024 11:23:18 -0400 Subject: [PATCH] fix(druid): handle typed nulls where possible (#9452) --- ibis/backends/druid/compiler.py | 7 ++++++- ibis/backends/tests/test_aggregation.py | 9 --------- ibis/backends/tests/test_string.py | 14 +------------- 3 files changed, 7 insertions(+), 23 deletions(-) diff --git a/ibis/backends/druid/compiler.py b/ibis/backends/druid/compiler.py index 1e217ff2f84d..19a81c6d07ad 100644 --- a/ibis/backends/druid/compiler.py +++ b/ibis/backends/druid/compiler.py @@ -146,7 +146,12 @@ def visit_StringSQLILike(self, op, *, arg, pattern, escape): def visit_Literal(self, op, *, value, dtype): if value is None: - return NULL + # types that cannot be cast to NULL are null, and temporal types + # and druid doesn't have a bytes type so don't cast that + if dtype.is_null() or dtype.is_temporal() or dtype.is_binary(): + return NULL + else: + return self.cast(NULL, dtype) return super().visit_Literal(op, value=value, dtype=dtype) def visit_NonNullLiteral(self, op, *, value, dtype): diff --git a/ibis/backends/tests/test_aggregation.py b/ibis/backends/tests/test_aggregation.py index 56fc920f2393..b020be389564 100644 --- a/ibis/backends/tests/test_aggregation.py +++ b/ibis/backends/tests/test_aggregation.py @@ -1567,15 +1567,6 @@ def test_group_by_expr(backend, con): reason="nulls are discarded by default in group bys", raises=IndexError, ), - pytest.mark.notyet( - ["druid"], - raises=PyDruidProgrammingError, - reason=( - "druid resists typed nulls for reasons unrelated to grouping," - " and this is compiled as an untyped NULL " - "which of course isn't allowed in a group by" - ), - ), ], ), ], diff --git a/ibis/backends/tests/test_string.py b/ibis/backends/tests/test_string.py index 423b116e440d..ceb9fdc77711 100644 --- a/ibis/backends/tests/test_string.py +++ b/ibis/backends/tests/test_string.py @@ -16,7 +16,6 @@ ClickHouseDatabaseError, OracleDatabaseError, PsycoPg2InternalError, - PyDruidProgrammingError, PyODBCProgrammingError, ) from ibis.common.annotations import ValidationError @@ -802,18 +801,7 @@ def test_parse_url(con, result_func, expected): @pytest.mark.parametrize( ("inp, expected"), [ - param( - None, - None, - id="none", - marks=[ - pytest.mark.notyet( - ["druid"], - raises=PyDruidProgrammingError, - reason="illegal use of NULL", - ) - ], - ), + param(None, None, id="none"), param( "", "",