diff --git a/polars/polars-core/src/series/comparison.rs b/polars/polars-core/src/series/comparison.rs index b9ad98d3132e..00dfcb9bea76 100644 --- a/polars/polars-core/src/series/comparison.rs +++ b/polars/polars-core/src/series/comparison.rs @@ -1,12 +1,6 @@ //! Comparison operations on Series. -#[cfg(any( - feature = "dtype-duration", - feature = "dtype-datetime", - feature = "dtype-date", - feature = "dtype-time", - feature = "dtype-struct" -))] +#[cfg(feature = "dtype-struct")] use std::ops::Deref; use super::Series; diff --git a/polars/polars-lazy/src/physical_plan/expressions/apply.rs b/polars/polars-lazy/src/physical_plan/expressions/apply.rs index cae2bcbed458..a5a8fd79d00c 100644 --- a/polars/polars-lazy/src/physical_plan/expressions/apply.rs +++ b/polars/polars-lazy/src/physical_plan/expressions/apply.rs @@ -443,6 +443,11 @@ impl ApplyExpr { } => (function, input), _ => return Ok(true), }; + // ensure the input of the function is only a `col(..)` + // if it does any arithmetic the code below is flawed + if !matches!(input[0], Expr::Column(_)) { + return Ok(true); + } match function { FunctionExpr::Boolean(BooleanFunction::IsNull) => { diff --git a/py-polars/tests/unit/io/test_lazy_parquet.py b/py-polars/tests/unit/io/test_lazy_parquet.py index bc461c3adecc..1c7848ff3c6f 100644 --- a/py-polars/tests/unit/io/test_lazy_parquet.py +++ b/py-polars/tests/unit/io/test_lazy_parquet.py @@ -376,3 +376,16 @@ def test_glob_n_rows(io_files_path: Path) -> None: "fats_g": [0.5, 6.0], "sugars_g": [2, 2], } + + +@pytest.mark.write_disk() +def test_parquet_statistics_filter_9925(tmp_path: Path) -> None: + tmp_path.mkdir(exist_ok=True) + file_path = tmp_path / "codes.parquet" + df = pl.DataFrame({"code": [300964, 300972, 500_000, 26]}) + df.write_parquet(file_path, statistics=True) + + q = pl.scan_parquet(file_path).filter( + (pl.col("code").floordiv(100_000)).is_in([0, 3]) + ) + assert q.collect().to_dict(False) == {"code": [300964, 300972, 26]}