{{ message }}
[SPARK-59513][PYTHON] Compare Row lengths in assertDataFrameEqual - #58789
Open
laserninja wants to merge 1 commit into
Open
laserninja wants to merge 1 commit into
laserninja wants to merge 1 commit into
Conversation
HyukjinKwon
reviewed
Sep 15, 2026
Member
There was a problem hiding this comment.
compare_vals: addinglen(val1) == len(val2)to theRowbranch is the right fix and
mirrors the existinglistanddictbranches. TheRowbranch is reachable because
Rowis atuplesubclass, not alist, so thelistbranch above does not intercept
it. And since list/dict values recurse back intocompare_vals, the length check also
protects Rows nested inside lists and maps -- which the new tests exercise.- Tests: good coverage -- both argument orders, plain/nested-Row/array/map wrapping, and
bothcheckRowOrdervalues.unittest.TestCaseis the right base here (no SparkSession
is needed for list-of-Row inputs). Imports and line lengths are clean.
One process nit: this is a user-facing behavior change to a public API (assertDataFrameEqual
now raises DIFFERENT_ROWS on an arity mismatch), so it should carry a SPARK-xxxxx JIRA in
the title rather than a bare [PYTHON] tag. You already note the Jira is pending -- worth
creating it and updating the title before merge.
Nothing blocking in the code.
laserninja
force-pushed
the
fix/row-comparison-arity
branch
from
September 15, 2026 01:16
305566e to
9a6f5d9
Compare
Author
laserninja
marked this pull request as ready for review
September 15, 2026 02:32
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?
Jira: SPARK-59513
Check Row lengths before recursively comparing field values. Add tests for either side having extra fields, empty Rows, nested Rows, arrays, maps, and both row-order settings.
Why are the changes needed?
The Row comparator uses zip without a length check, so trailing fields are ignored. List-of-Row inputs are supported and do not undergo a DataFrame schema comparison, allowing unequal results to pass assertions.
Does this PR introduce any user-facing change?
Yes. assertDataFrameEqual raises DIFFERENT_ROWS when corresponding Rows contain different numbers of fields, including nested Rows.
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 2 tests, including parameterized subtests:
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).