Skip to content

[GH-3333] Handle leading nulls in local GeoSeries construction - #3349

Open
jiayuasu wants to merge 1 commit into
apache:masterfrom
jiayuasu:fix/geoseries-leading-nulls
Open

[GH-3333] Handle leading nulls in local GeoSeries construction#3349
jiayuasu wants to merge 1 commit into
apache:masterfrom
jiayuasu:fix/geoseries-leading-nulls

Conversation

@jiayuasu

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?

Closes #3333.

What changes were proposed in this PR?

On Spark 3.5, local input such as GeoSeries([None, Point(1, 2)]) fails with ArrowInvalid: pandas-on-Spark checks the first value to infer the geometry type, so a leading null prevents it from recognizing later geometries.

For local input that starts with a missing value and contains a geometry, normalize missing entries, encode the values as well-known binary (WKB) with embedded SRIDs, and construct the geometry column with ST_GeomFromWKB. Restore the original Series name after WKB conversion. This preserves input order, index, name, geometry dimensions, and existing CRS handling. Other constructor paths remain unchanged.

How was this patch tested?

The new tests produced 13 ArrowInvalid failures on the unchanged Spark 3.5 constructor, with three controls passing. A separate regression check caught both pandas and NumPy NaT values before missing-value normalization was added.

31 focused GeoSeries constructor, conversion, and CRS tests passed on each of Spark 3.5.0 and 4.1.1. Coverage includes local list, tuple, NumPy, pandas, GeoPandas, and GeometryArray inputs; missing-value variants; duplicate MultiIndex order; names; inherited and explicit CRS; empty geometries; and embedded SRID/Z preservation.

Current Python source was tested with cached JVM jars: released Sedona 1.9.1 for Spark 3.5 and a prior local 2.0.0-SNAPSHOT build for Spark 4.1. No fresh JVM rebuild was performed. Formatting and pre-commit checks passed.

Did this PR include necessary documentation updates?

No documentation changes are needed. This fixes an existing constructor path without changing the public API.

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.

GeoPandas: GeoSeries constructor fails for leading-null local input on Spark 3.5

1 participant