Skip to content

Commit

Permalink
fix(python): Handle boolean comparisons in Iceberg predicate pushdown (
Browse files Browse the repository at this point in the history
  • Loading branch information
dimfeld authored Jan 25, 2025
1 parent 45a5d8e commit 8552f60
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
2 changes: 2 additions & 0 deletions py-polars/polars/io/iceberg.py
Original file line number Diff line number Diff line change
Expand Up @@ -263,6 +263,8 @@ def _(a: Call) -> Any:
f = _convert_predicate(a.func)
if f == "field":
return args
elif f == "scalar":
return args[0]
elif f in _temporal_conversions:
# convert from polars-native i64 to ISO8601 string
return _temporal_conversions[f](*args).isoformat()
Expand Down
9 changes: 9 additions & 0 deletions py-polars/tests/unit/io/test_iceberg.py
Original file line number Diff line number Diff line change
Expand Up @@ -176,3 +176,12 @@ def test_parse_lteq(self) -> None:

expr = _to_ast("(pa.compute.field('ts') <= '2023-08-08')")
assert _convert_predicate(expr) == LessThanOrEqual("ts", "2023-08-08")

def test_compare_boolean(self) -> None:
from pyiceberg.expressions import EqualTo

expr = _to_ast("(pa.compute.field('ts') == pa.compute.scalar(True))")
assert _convert_predicate(expr) == EqualTo("ts", True)

expr = _to_ast("(pa.compute.field('ts') == pa.compute.scalar(False))")
assert _convert_predicate(expr) == EqualTo("ts", False)

0 comments on commit 8552f60

Please sign in to comment.