Skip to content

[SPARK-58465][PS] Use native expressions for NumPy reciprocal of floating-point columns - #57668

Open
zhengruifeng wants to merge 1 commit into
apache:masterfrom
zhengruifeng:pandas-native-reciprocal-dev2
Open

[SPARK-58465][PS] Use native expressions for NumPy reciprocal of floating-point columns#57668
zhengruifeng wants to merge 1 commit into
apache:masterfrom
zhengruifeng:pandas-native-reciprocal-dev2

Conversation

@zhengruifeng

@zhengruifeng zhengruifeng commented Jul 31, 2026

Copy link
Copy Markdown
Contributor

What changes were proposed in this pull request?

Use native Spark SQL expressions for NumPy reciprocal on pandas-on-Spark columns with Spark float or double types. The expressions preserve nulls, NaN, infinity, and signed zero. Inputs with other types continue to use the existing pandas UDF.

Why are the changes needed?

Native expressions avoid the Python worker boundary for floating-point reciprocal while retaining the established behavior for input types with NumPy-specific semantics.

Does this PR introduce any user-facing change?

No. The behavior and result type remain unchanged.

How was this patch tested?

  • Added reciprocal coverage for negative zero in NumPyCompatTests.test_np_math_functions.
  • Passed NumPyCompatTests.test_np_math_functions and NumPyCompatTests.test_np_spark_compat_series.
  • Passed Ruff format and lint checks for python/pyspark/pandas/numpy_compat.py.

Was this patch authored or co-authored using generative AI tooling?

Generated-by: Codex (GPT-5)

@zhengruifeng
zhengruifeng marked this pull request as draft July 31, 2026 09:59
@zhengruifeng zhengruifeng changed the title [SPARK-58465][PS] Use native expressions for NumPy reciprocal ufunc [SPARK-58465][PS] Use native expressions for NumPy reciprocal of floating-point columns Jul 31, 2026
@zhengruifeng
zhengruifeng marked this pull request as ready for review July 31, 2026 12:06
@zhengruifeng
zhengruifeng force-pushed the pandas-native-reciprocal-dev2 branch from c2d632e to 760dc20 Compare July 31, 2026 12:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant