ViktorBystrov72 opened a new pull request, #60489: URL: https://github.com/apache/spark/pull/60489
### What changes were proposed in this pull request? Group NaN inputs in `NumericHistogram.add` using Spark SQL double ordering, and combine NaN bins before trimming merged partial histograms. Preserve the existing finite-value trimming algorithm and signed-zero equality. Add Catalyst and SQL regressions and a migration note. ### Why are the changes needed? [SPARK-61525](https://issues.apache.org/jira/browse/SPARK-61525) reports that `histogram_numeric` loses a finite input even when enough bins are available for all distinct values. Primitive comparisons do not recognize repeated NaNs as equal, and duplicate NaN bins can displace finite bins when partial histograms merge. ### Does this PR introduce _any_ user-facing change? Yes. For inputs `[NaN, NaN, 1.0]` and two requested bins, the result changes from `[{NaN, 2}, {NaN, 1}]` to `[{1.0, 1}, {NaN, 2}]`. This agrees with Spark SQL's NaN grouping semantics for both one and two input partitions. ### How was this patch tested? The new NaN regressions failed on the original implementation and pass with this change. After rebasing onto current master: - `catalyst/testOnly *HistogramNumericSuite`: 14 tests passed, including input permutations, serialized partial merges, repeated NaN, and finite/signed-zero controls. - `sql/testOnly *DataFrameAggregateSuite -- -z histogram_numeric`: 3 tests passed, including one and two input partitions and two and four requested bins. - `catalyst/Compile/checkstyle`, `catalyst/Test/scalastyle`, and `sql/Test/scalastyle`: passed. - Apache RAT: passed with the repository exclusions plus the `.git` worktree metadata file. The stock license script flags that metadata file; no source exclusions were added. The SQL suite emitted its existing possible-daemon-thread-leak warning, also seen in the baseline run, and exited successfully. ### Was this patch authored or co-authored using generative AI tooling? Generated-by: OpenAI Codex (GPT-6; exact tool build unavailable). Codex assisted with the implementation, regression tests, migration note, and this description. -- 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]
