diff --git a/vortex-python/python/vortex/polars_.py b/vortex-python/python/vortex/polars_.py index 03040371a3c..a8b3102761b 100644 --- a/vortex-python/python/vortex/polars_.py +++ b/vortex-python/python/vortex/polars_.py @@ -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}") diff --git a/vortex-python/test/test_polars_.py b/vortex-python/test/test_polars_.py index 554087ae93b..759ea605eb7 100644 --- a/vortex-python/test/test_polars_.py +++ b/vortex-python/test/test_polars_.py @@ -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]