Repository navigation
Conversation
### What changes were proposed in this pull request? Jira: [SPARK-59514](https://issues.apache.org/jira/browse/SPARK-59514) Compare NaN and infinity explicitly before applying finite-value tolerances. Preserve matching NaNs and same-sign infinities, and add tests for both argument directions, zero/default tolerances, and nested values. ### Why are the changes needed? The tolerance inequality does not reject NaN arithmetic, and an infinite expected value can make both sides infinity. As a result, NaN versus a finite value and opposite-sign infinities can pass equality assertions. ```python from pyspark.sql import Row from pyspark.testing import assertDataFrameEqual assertDataFrameEqual([Row(x=float("nan"))], [Row(x=1.0)]) assertDataFrameEqual([Row(x=1.0)], [Row(x=float("inf"))]) assertDataFrameEqual([Row(x=float("inf"))], [Row(x=float("-inf"))]) # All three return without raising ``` ### Does this PR introduce _any_ user-facing change? Yes. Unequal special values now raise DIFFERENT_ROWS. Matching NaNs and same-sign infinities continue to compare equal, and finite-value tolerance behavior is unchanged. ### How was this patch tested? The new regression tests failed before the fix and passed afterward on Python 3.10.11 with NumPy 2.2.6. The focused run passed 3 tests, including parameterized subtests: ```bash PYTHONPATH=python TERM=dumb python -m unittest pyspark.sql.tests.test_utils.NonFiniteComparisonTests -q PYTHON_EXECUTABLE=python ./dev/lint-python --compile --custom-pyspark-error --ruff ``` Run the commands with the Python virtual environment activated; the local run shared an environment from a sibling checkout. The tests call public Python APIs directly and require no SparkSession. Python compilation, custom-error checks, Ruff lint, and Ruff formatting passed. JVM-backed suites were not run because these fixes are confined to Python-side logic. ### Was this patch authored or co-authored using generative AI tooling? Generated-by: OpenAI Codex (GPT-6). Closes apache#58790 from laserninja/fix/nonfinite-comparison. Authored-by: Akshay Thorat <ak007t@gmail.com> Signed-off-by: Holden Karau <holden.karau@snowflake.com> (cherry picked from commit d237fdb) Signed-off-by: Holden Karau <holden.karau@snowflake.com>
holdenk
force-pushed
the
backport-pr58790-branch-4.x
branch
from
November 25, 2026 05:12
92eb905 to
e44ce57
Compare
…rmExpressionSuite Add IntBucketFunction and ProduceResultBucketFunction to TransformExpressionSuite. The SPARK-62319 backport uses them, but they come from SPARK-60541, which is not on branch-4.x, so catalyst test compilation fails. Co-authored-by: Isaac <no-reply@databricks.com> (cherry picked from commit 9dceb9d) NOTE: TEMPORARY cherry-pick of apache#60866 (not part of this backport) so CI can compile TransformExpressionSuite on this branch. Once that fix is merged into the release branch this commit drops out on rebase; do not merge it as part of this PR.
This branch has not been deployed
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.
Backport of #58790 to
branch-4.x, cherry-picked from d237fdb.Opened by
dev/merge_spark_pr.py. Merging this PR with the script commits its first commit's message, which keeps #58790's message, footer and author, and addsBackport-PRwith this PR's number and the merger's sign-off. Fixups go in as further commits; their authors getCo-authored-by.