Skip to content

[GH-3124] Preserve GeoSeries indexes in to_geoframe - #3538

Merged
jiayuasu merged 1 commit into
apache:masterfrom
jiayuasu:gh-3124-geoseries-geoframe-axes
Nov 11, 2026
Merged

jiayuasu merged 1 commit into
apache:masterfrom
jiayuasu:gh-3124-geoseries-geoframe-axes

Conversation

@jiayuasu

@jiayuasu jiayuasu commented Nov 11, 2026 •

Copy link
Copy Markdown
Member

Did you read the Contributor Guide?

Yes, I have read the Contributor Rules and Contributor Development Guide.

Is this PR related to a ticket?

Related to #3124. This is an independent GeoPandas fix used by #3391; it does not close the Spark native spatial support issue and does not depend on native types or the spatial type predicate PR.

What changes were proposed in this PR?

GeoSeries.to_geoframe() currently converts through a Spark DataFrame using one physical index column name. A series with a MultiIndex therefore fails with a mismatch between its two index levels and the one supplied index name.

Construct the GeoDataFrame directly from the series' existing pandas-on-Spark InternalFrame. This retains index levels and names, duplicate labels, null geometry values, CRS metadata and pending column expressions. Existing default and explicit geometry-column naming are preserved. Remove the now-unused single-index constant and update a stale test comment.

The change is limited to two Python files and works with the existing Sedona UDT implementation. It changes no serializer or spatial execution path.

How was this patch tested?

Validated commit 457518688539544090a885308ef50f79291a5b91.

  • Reproduced the MultiIndex failure before the production change, including named/unnamed/renamed geometry columns and an all-null geometry column with a declared CRS.
  • pytest -q tests/geopandas/test_geoseries.py -k to_geoframe_preserves: all eight focused cases passed on Spark 4.1. Coverage compares full collected GeoDataFrames with GeoPandas and checks source preservation, duplicate axes, nulls, CRS, geometry naming, and lazy expressions with pending aliases.
  • Built a fresh Spark 4.1.1 / Scala 2.13 shaded artifact from standalone base eaca7639f2ed7b754951af5d64a5deeed1cec5cd with mvn -o -B -Dspark=4.1 -Dspark.version=4.1.1 -Dscala=2.13 -Dgeotools -Dmaven.javadoc.skip=true -Dmaven.jar.forceCreation=true -pl spark-shaded -am -DskipTests clean install.
  • With that artifact, the complete test_geoseries.py and test_geodataframe.py run passed 516 tests; four others stopped in the isolated launcher because Spark was initialized before the test fixture's SparkContext property. Initializing TestBase.sc first made all four pass, together with all eight new cases (12 passed). No repository workaround or skip was added. All 520 selected cases therefore passed across the full run and focused rerun.
  • With the finalized tests and same artifact, unchanged master fails all five MultiIndex cases while its three single-index controls pass. Restoring this fix passes all eight cases.
  • Repository-pinned formatting and normal commit hooks passed; independent review found no further issue. Current-head Python CI and the other applicable matrices are pending; no current-head failure was observed at the publication check.

Did this PR include necessary documentation updates?

No new API is introduced. The existing to_geoframe naming contract remains unchanged, and the test comment claiming MultiIndex was unsupported is updated alongside the new regression coverage.

@jiayuasu
jiayuasu marked this pull request as ready for review November 11, 2026 20:10
@jiayuasu jiayuasu added this to the sedona-2.0.0 milestone Nov 11, 2026
@jiayuasu
jiayuasu merged commit d7fd307 into apache:master Nov 11, 2026
34 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant