adiranjan25 opened a new pull request, #60014:
URL: https://github.com/apache/spark/pull/60014

   ### What changes were proposed in this pull request?
   
   Fix pandas API on Spark `sum()` when floating-point expressions generate NaN 
at runtime.
   
   The implementation uses the existing `nan_to_null()` helper to convert NaN 
into SQL NULL before aggregation, preserving the Boolean-to-integer conversion.
   
   ### Why are the changes needed?
   
   Spark's SQL `sum()` propagates IEEE NaN, whereas pandas skips NaN by default.
   
   For example, `np.cos()` applied to `[1.0, np.inf, 2.0]` previously produced:
   
   - pandas: `0.12415546932099736`
   - pandas-on-Spark: `nan`
   
   With this patch, both return `0.12415546932099736`.
   
   ### How was this patch tested?
   
   - Added regression test `test_sum_with_runtime_generated_nan`.
   - Verified default `skipna`, `skipna=False`, `min_count=2`, and 
`min_count=3`.
   - Existing `test_sum` passed.
   - Boolean aggregation verified.
   - Ruff formatting and `git diff --check` passed.
   
   Closes SPARK-60657.


-- 
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]

Reply via email to