Spenserrrr opened a new pull request, #58509: URL: https://github.com/apache/spark/pull/58509
### What changes were proposed in this pull request? `maybe_dispatch_ufunc_to_spark_func` now casts a boolean operand to `tinyint` before building the expression, the way NumPy promotes one to `int8` before it picks a loop. `np.invert` and `np.negative` reuse the existing `logical_not` mapping instead, since NumPy reads a boolean logically for those two. ### Why are the changes needed? Most ufuncs in the mapping tables raise `AnalysisException` on a boolean column, because Spark's functions have no implicit boolean-to-numeric cast, where pandas returns a value: `np.sqrt(ps.Series([True, False]))` fails while pandas answers `[1.0, 0.0]`. ### Does this PR introduce _any_ user-facing change? Yes. A NumPy ufunc on a boolean column now returns a value instead of raising; the values match pandas, while the result dtype follows Spark's math functions, which return double. ### How was this patch tested? New `test_np_boolean_operand` and `test_np_boolean_operand_logical` in `NumPyCompatTestsMixin`, both of which fail without the change. ### Was this patch authored or co-authored using generative AI tooling? Generated-by: Claude Code (Claude Opus 5) -- 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]
