Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions vortex-python/python/vortex/polars_.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,8 @@ def _polars_to_vortex(expr: dict[str, Any]) -> ve.Expr:
elif "Decimal" in scalar:
value, precision, scale = scalar["Decimal"]
return ve.literal(_dtype.decimal(precision=precision, scale=scale), value)
elif len(scalar) == 1 and next(iter(scalar)) in _LITERAL_TYPES:
dtype, value = next(iter(scalar.items()))
else:
raise ValueError(f"Cannot convert to Vortex: unsupported Polars scalar value type {scalar}")

Expand Down
20 changes: 20 additions & 0 deletions vortex-python/test/test_polars_.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,3 +129,23 @@ def test_polars_is_between(tmp_path, closed, expected):
actual = vx.open(str(path)).to_polars().filter(expr).collect()
assert_frame_equal(actual, expected_frame)
assert actual["id"].to_list() == expected


@pytest.mark.parametrize(
"arrow_type, threshold",
[(pa.uint8(), 50), (pa.uint16(), 500), (pa.uint32(), 500), (pa.uint64(), 500)],
)
def test_unsigned_predicate_pushdown(tmp_path, arrow_type, threshold):
table = pa.table(
{
"id": [0, 1, 2],
"value": pa.array([threshold - 1, threshold, threshold + 1], type=arrow_type),
}
)
path = tmp_path / "unsigned.vortex"
vx.io.write(vx.array(table), str(path))
expr = pl.col("value") >= threshold
expected = pl.DataFrame(table).lazy().filter(expr).collect()
result = vx.open(str(path)).to_polars().filter(expr).collect()
assert_frame_equal(result, expected)
assert result["id"].to_list() == [1, 2]
Loading