[SPARK-58533][PS] Use native Spark function for NumPy float_power - #57734
Closed
zhengruifeng wants to merge 2 commits into
Closed
[SPARK-58533][PS] Use native Spark function for NumPy float_power#57734zhengruifeng wants to merge 2 commits into
zhengruifeng wants to merge 2 commits into
Conversation
Yicong-Huang
approved these changes
Aug 4, 2026
| } | ||
| ), | ||
| ): | ||
| with self.subTest(base=pdf.base.tolist(), exponent=pdf.exponent.tolist()): |
Contributor
There was a problem hiding this comment.
nit: do we want to avoid using subTest?
HyukjinKwon
approved these changes
Aug 4, 2026
zhengruifeng
added a commit
that referenced
this pull request
Aug 4, 2026
### What changes were proposed in this pull request? This PR replaces the pandas UDF implementation of `np.float_power` in pandas API on Spark with native Spark `pow`, casting both operands to `double`. It also adds compatibility coverage for integral inputs and floating-point special values. ### Why are the changes needed? Using a native Spark expression avoids pandas UDF and Arrow overhead while preserving NumPy `float_power` floating-point semantics. ### Does this PR introduce _any_ user-facing change? No. ### How was this patch tested? Added `test_np_float_power`, covering integral inputs, signed zero, infinities, and NaN. - `ruff check python/pyspark/pandas/numpy_compat.py python/pyspark/pandas/tests/test_numpy_compat.py` - `ruff format --check python/pyspark/pandas/numpy_compat.py python/pyspark/pandas/tests/test_numpy_compat.py` - `python/run-tests --testnames pyspark.pandas.tests.test_numpy_compat` (`test_np_float_power` passed; the module has two unrelated existing reciprocal pandas-UDF failures due to a local Python/JVM class-signature mismatch.) ### Was this patch authored or co-authored using generative AI tooling? Generated-by: Codex GPT-5 Closes #57734 from zhengruifeng/pandas-native-float-power-dev2. Authored-by: Ruifeng Zheng <ruifengz@apache.org> Signed-off-by: Ruifeng Zheng <ruifengz@foxmail.com> (cherry picked from commit ad9c532) Signed-off-by: Ruifeng Zheng <ruifengz@foxmail.com>
Contributor
Author
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What changes were proposed in this pull request?
This PR replaces the pandas UDF implementation of
np.float_powerin pandas API on Spark with native Sparkpow, casting both operands todouble. It also adds compatibility coverage for integral inputs and floating-point special values.Why are the changes needed?
Using a native Spark expression avoids pandas UDF and Arrow overhead while preserving NumPy
float_powerfloating-point semantics.Does this PR introduce any user-facing change?
No.
How was this patch tested?
Added
test_np_float_power, covering integral inputs, signed zero, infinities, and NaN.ruff check python/pyspark/pandas/numpy_compat.py python/pyspark/pandas/tests/test_numpy_compat.pyruff format --check python/pyspark/pandas/numpy_compat.py python/pyspark/pandas/tests/test_numpy_compat.pypython/run-tests --testnames pyspark.pandas.tests.test_numpy_compat(test_np_float_powerpassed; the module has two unrelated existing reciprocal pandas-UDF failures due to a local Python/JVM class-signature mismatch.)Was this patch authored or co-authored using generative AI tooling?
Generated-by: Codex GPT-5