Yicong-Huang opened a new pull request, #57836: URL: https://github.com/apache/spark/pull/57836
### What changes were proposed in this pull request? Replace the `numpy.copysign` pandas UDF mapping in `python/pyspark/pandas/numpy_compat.py` with a native Spark SQL expression (umbrella: SPARK-58532). `copysign(x, y)` returns `|x|` with the sign of `y`. The sign is taken from `y`'s IEEE-754 sign bit: `-0.0` counts as negative (detected via a string cast, as the existing `reciprocal` mapping does) rather than via `y < 0`, which misses `-0.0`. NaN falls through to a positive sign. Null handling is type-aware: a float `y` column carries missing values as NaN (surfaced as NULL), where `copysign(x, NaN)` is `|x|`; an integer `y` column's NULL is genuine and propagates. ### Why are the changes needed? Native expressions avoid pandas UDF serialization/worker overhead and work uniformly on classic and Spark Connect. ### Does this PR introduce _any_ user-facing change? No. ### How was this patch tested? Added `test_np_copysign` and `test_np_copysign_signed_zero` (also run via the Spark Connect parity suite), covering integer/float/nullable-integer inputs and asserting `np.signbit` for the signed-zero, NaN, null, and `+-inf` edge cases. ### Was this patch authored or co-authored using generative AI tooling? No. -- 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]
