Skip to content

Commit

Permalink
fix(druid): handle typed nulls where possible (#9452)
Browse files Browse the repository at this point in the history
  • Loading branch information
cpcloud authored Jun 27, 2024
1 parent 14f1821 commit 33ec754
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 23 deletions.
7 changes: 6 additions & 1 deletion ibis/backends/druid/compiler.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
9 changes: 0 additions & 9 deletions ibis/backends/tests/test_aggregation.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
),
),
],
),
],
Expand Down
14 changes: 1 addition & 13 deletions ibis/backends/tests/test_string.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
ClickHouseDatabaseError,
OracleDatabaseError,
PsycoPg2InternalError,
PyDruidProgrammingError,
PyODBCProgrammingError,
)
from ibis.common.annotations import ValidationError
Expand Down Expand Up @@ -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(
"",
"",
Expand Down

0 comments on commit 33ec754

Please sign in to comment.