sohailshk opened a new pull request, #27289:
URL: https://github.com/apache/datafusion/pull/27289
## Which issue does this PR close?
- Closes #25913.
## Rationale for this change
Follows up the closed #25971 and also covers the
List/LargeList/FixedSizeList element paths kosiew pointed out in its review.
Spark computes `xxhash64` of a float from
`floatToIntBits`/`doubleToLongBits`, and both map every NaN to one bit pattern.
`datafusion-spark` hashed the raw bits, so `-NaN` or a NaN with a payload
hashed differently from `NaN`. The hash decides shuffle partitioning in
Spark-compatible engines, so equal values could land in different partitions.
## What changes are included in this PR?
Two helpers in `datafusion/spark/src/function/hash/utils.rs`,
`f32_hash_bytes` and `f64_hash_bytes`, map every NaN to the canonical bit
pattern and keep `-0.0 -> 0`. They replace the three inline copies of the
`-0.0` check: the `hash_array_primitive_float!` macro (float columns) and the
two element paths for `List`/`LargeList` and `FixedSizeList`.
## What is the testing strategy for this PR?
- Unit tests in `xxhash64.rs` for f32 and f64 (sign bit, payload, signalling
NaN) and for List/LargeList/FixedSizeList of both.
- `xxhash64.slt`: `xxhash64(arrow_cast('NaN', ...))` and its negation for
Float32 and Float64.
- The Float64 value is Spark's, from #25913; the Float32 value is the hash
of `0x7fc00000` (also given in #25913).
- The list test covers List, LargeList and FixedSizeList of Float32 and
Float64; it fails if the FixedSizeList change is reverted. All new tests fail
on `main` and pass here.
## Are there any user-facing changes?
`xxhash64` returns Spark's value for NaNs with a sign bit or payload. No API
change.
--
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]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]