[SPARK-58514][PS] Restore native NumPy log2 mapping - #57717
Closed
zhengruifeng wants to merge 2 commits into
Closed
Conversation
uros-b
approved these changes
Aug 3, 2026
Member
|
LGTM, thank you @zhengruifeng! |
zhengruifeng
added a commit
that referenced
this pull request
Aug 4, 2026
### What changes were proposed in this pull request? Restore the pandas-on-Spark `np.log2` mapping using the native Spark SQL `log2` function. Preserve NumPy behavior for `0.0` and `-0.0`, for which NumPy returns `-inf` while Spark SQL returns null. Add end-to-end coverage for negative, zero, finite, infinite, and NaN inputs. ### Why are the changes needed? SPARK-58249 unintentionally removed the existing `np.log2` mapping while replacing other NumPy mappings with native Spark SQL expressions. Spark already provides an equivalent native function, with an explicit zero branch needed to match NumPy semantics. ### Does this PR introduce _any_ user-facing change? Yes. `np.log2` on pandas-on-Spark objects is dispatched to Spark SQL again instead of being unsupported by the NumPy compatibility mapping. ### How was this patch tested? Added end-to-end pandas-on-Spark coverage for `np.log2` edge cases. Ran: - `python/run-tests --testnames pyspark.pandas.tests.test_numpy_compat` - `python/run-tests --testnames pyspark.pandas.tests.connect.test_parity_numpy_compat` - Ruff check and format check - `git diff --check`, source ASCII, and line-length checks ### Was this patch authored or co-authored using generative AI tooling? Generated-by: Codex (GPT-5) Closes #57717 from zhengruifeng/pandas-native-log2-dev2. Authored-by: Ruifeng Zheng <ruifengz@apache.org> Signed-off-by: Ruifeng Zheng <ruifengz@foxmail.com> (cherry picked from commit 3e2bb12) 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?
Restore the pandas-on-Spark
np.log2mapping using the native Spark SQLlog2function. Preserve NumPy behavior for0.0and-0.0, for which NumPy returns-infwhile Spark SQL returns null. Add end-to-end coverage for negative, zero, finite, infinite, and NaN inputs.Why are the changes needed?
SPARK-58249 unintentionally removed the existing
np.log2mapping while replacing other NumPy mappings with native Spark SQL expressions. Spark already provides an equivalent native function, with an explicit zero branch needed to match NumPy semantics.Does this PR introduce any user-facing change?
Yes.
np.log2on pandas-on-Spark objects is dispatched to Spark SQL again instead of being unsupported by the NumPy compatibility mapping.How was this patch tested?
Added end-to-end pandas-on-Spark coverage for
np.log2edge cases.Ran:
python/run-tests --testnames pyspark.pandas.tests.test_numpy_compatpython/run-tests --testnames pyspark.pandas.tests.connect.test_parity_numpy_compatgit diff --check, source ASCII, and line-length checksWas this patch authored or co-authored using generative AI tooling?
Generated-by: Codex (GPT-5)