[GH-3084] Align GeoPandas test comparison by index (results are unordered)#3085
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Updates the shared GeoPandas test helper to avoid false negatives when Sedona operations return results in a non-deterministic row order (e.g., due to Spark partition shuffles), by aligning comparisons on index rather than position.
Changes:
- Sort both actual (
to_geopandas()) and expectedGeoSeriesby index before element-wise comparison. - Update index equality assertion to compare the aligned (sorted) indices.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
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.
Did you read the Contributor Guide?
Yes
Is this PR related to a ticket?
Yes, resolves #3084
What changes were proposed in this PR?
check_sgpd_equals_gpdinpython/tests/geopandas/test_geopandas_base.pycompared the actualGeoSeriesagainst the expectedgpd.GeoSerieselement-wise by position and asserted index equality positionally. This assumed the result preserved input row order.Sedona's GeoPandas API does not guarantee result row ordering, so operations that shuffle across Spark partitions (e.g.
GeoSeries.clip_by_rect) can return rows in a different order, causing false test failures (test_clip_by_rectreportsPOLYGON EMPTYvs the expected clipped polygon even though all values are correct).This PR aligns both sides by index before comparing, making the helper order-agnostic. It is a no-op for operations that already return ordered results.
How was this patch tested?
Ran
test_clip_by_rect(bothtest_geoseries.pyandtest_match_geopandas_series.py) andtest_bufferwith a multi-partition local Spark (local[*]); all pass with the fix and the previously-failingclip_by_rectcases now compare correctly.Did this PR include necessary documentation updates?
No, this is a test-only change.