zhaohaisun commented on issue #55886:
URL: https://github.com/apache/arrow/issues/55886#issuecomment-7372425385
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):
```python
import pyarrow as pa, pyarrow.parquet as pq, pyarrow.dataset as ds,
pyarrow.compute as pc
t = pa.table({"x": pa.array([16777217, 20000000], pa.int32())})
pq.write_table(t, "with_stats.parquet")
pq.write_table(t, "no_stats.parquet", write_statistics=False)
e = pc.field("x").cast(pa.float32(), safe=False) <= pa.scalar(16777216.0,
pa.float32())
print(t.filter(e).num_rows) # 1
(16777217 -> 16777216.0)
print(ds.dataset("no_stats.parquet").to_table(filter=e).num_rows) # 1
ds.dataset("with_stats.parquet").to_table(filter=e) #
ArrowInvalid
```
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._
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]