You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[Python][C++][Dataset] Parquet row groups are skipped for comparisons on cast(x, float32) when x is float64 #55886
Describe the bug, including details regarding any error messages, version, and platform.
When a dataset filter compares a float64 column cast to float32 with a literal, Parquet row-group statistics can skip row groups that contain matching rows. Without statistics, or on an in-memory table, the same filter matches.
17.799999999999997 cast to float32 is 17.799999237060547, so the first row matches. The >= direction fails the same way:
t=pa.table({"x": pa.array([1.0, 17.8000008])})
e=pc.field("x").cast(pa.float32()) >=pa.scalar(17.80000114440918, pa.float32())
# with statistics: 0 rows; without statistics and in memory: 1 row
Cause, from reading the code: Inequality::Simplify in cpp/src/arrow/compute/expression.cc calls Comparison::StripOrderPreservingCasts on the left-hand side, then compares the float32 literal with the guarantee bound, which is in the column's own type (float64). StripOrderPreservingCasts in expression_internal.h strips every cast to a floating-point type whose source is an integer or floating-point type, including float64 -> float32. That cast is monotonic but rounds, so cast(x) <= c can hold while x > c, and comparing the literal with the uncast bound proves the row group empty when it is not.
A possible fix: strip only casts that are exact for every input (float32 -> float64, narrower -> wider integers, integer -> floating point only when the integer fits in the mantissa), or apply the same cast to the guarantee bound before comparing. SimplifyIsIn uses the same helper.
Reproduces on pyarrow 10.0.1, 12.0.1, 14.0.2, 15.0.2, 16.1.0, 17.0.0, 18.0.0, 20.0.0, 22.0.0, 24.0.0 and 26.0.1 (Linux x86_64, Python 3.11).
changed the title [-][C++][Dataset] Parquet row groups are skipped for comparisons on cast(x, float32) when x is float64[/-][+][Python][C++][Dataset] Parquet row groups are skipped for comparisons on cast(x, float32) when x is float64[/+]on Dec 1, 2026
Hi @zhaohaisun , could you take a look at PR #55941? If either of your original test cases still fails with the fix, could you share the result you get? Thanks for the clear repro :D
Thanks for the PR. I have not built #55941, but both original cases (cast(x, float32) <= c and >= c on a float64 column) are what its new Parquet tests cover, so I expect them to pass.
One related case that the patch leaves unchanged: integer → floating-point casts are still stripped, although they can round as well (int32/int64 above 2^24 for float32, int64 above 2^53 for float64). With an unsafe cast the scan then fails only when statistics are present (pyarrow 26.0.1):
The same happens for an int64 column cast to float64 with values above 2^53. With the default safe cast all three raise, so this only concerns safe=False. It may be worth applying the same rule as for float narrowing here (strip integer → floating-point only when every value of the source type is exactly representable), either in this PR or separately.
Drafted with Claude Code; reproduced and reviewed by me.
Activity
[-][C++][Dataset] Parquet row groups are skipped for comparisons on cast(x, float32) when x is float64[/-][+][Python][C++][Dataset] Parquet row groups are skipped for comparisons on cast(x, float32) when x is float64[/+]TatvagnaTandel commentedon Dec 3, 2026
Hi @zhaohaisun , could you take a look at PR #55941? If either of your original test cases still fails with the fix, could you share the result you get? Thanks for the clear repro :D
zhaohaisun commentedon Dec 3, 2026
Thanks for the PR. I have not built #55941, but both original cases (
cast(x, float32) <= cand>= con a float64 column) are what its new Parquet tests cover, so I expect them to pass.One related case that the patch leaves unchanged: integer → floating-point casts are still stripped, although they can round as well (int32/int64 above 2^24 for float32, int64 above 2^53 for float64). With an unsafe cast the scan then fails only when statistics are present (pyarrow 26.0.1):
The same happens for an int64 column cast to float64 with values above 2^53. With the default safe cast all three raise, so this only concerns
safe=False. It may be worth applying the same rule as for float narrowing here (strip integer → floating-point only when every value of the source type is exactly representable), either in this PR or separately.Drafted with Claude Code; reproduced and reviewed by me.