Skip to content

[GH-3369] Preserve empty components when setting SRID - #3377

Open
jiayuasu wants to merge 5 commits into
apache:masterfrom
jiayuasu:fix/set-srid-empty-components
Open

jiayuasu wants to merge 5 commits into
apache:masterfrom
jiayuasu:fix/set-srid-empty-components

Conversation

@jiayuasu

@jiayuasu jiayuasu commented Sep 16, 2026

Copy link
Copy Markdown
Member

Did you read the Contributor Guide?

Yes.

Is this PR related to a ticket?

Prerequisite for #3374 and #3369. Uses the merged JTS copy fix in jiayuasu/jts#10.

What changes were proposed in this PR?

ST_SetSRID currently removes empty members while copying a collection. For example, a collection containing an empty point and a populated point returns only the populated point after changing SRID. Empty polygon holes are also dropped. A standalone empty polygon can be returned as the original object, mutating its SRID rather than creating a copy.

Use the isolated JTS GeometryCopier with the requested SRID and the input's coordinate-sequence factory. This preserves every component and ring, including empty holes, and creates independent coordinate storage. Copies discard userData; the source geometry and its metadata remain unchanged. The copy logic is maintained in JTS, so this PR adds no Sedona geometry factory or serialization classes.

The dependency is the unpublished org.datasyslab:jts-io-patch:1.21.0-datasyslab-2 candidate. It uses stock JTS 1.20 geometry types and does not require replacing Spark's bundled JTS jar. Publication is pending the related PR reviews.

How was this patch tested?

The regressions fail against the base implementation and pass with the fix. They cover nested empty components, all three multipart types, empty polygon holes, empty-polygon input mutation, XYM/XYZ/XYZM layouts, packed sequences, geometry and factory SRIDs, independent copies, and source/userData preservation. A Spark SQL regression checks the empty-hole count before and after ST_SetSRID.

Full common suite on Java 11: 1,379 tests passed, zero failures/errors/skips. Validated against JTS candidate commit f00cd7103ef4e27dc1bbe59bbcc20af7b49d3da7.

Spark 3.5 and 4.1 each ran 287 selected Scala tests: 240 function tests and 46 constructor tests passed. The remaining MySQL constructor test could not start the local Docker environment and failed before Sedona assertions. The new SQL empty-hole regression passed on both profiles.

A stock PySpark 4.1.1 local[2] smoke test preserved empty polygon holes and all three empty collection members with SRID 4326. Geometry classes loaded from Spark's bundled JTS 1.20 jar; its SHA-256 was unchanged. All four isolated helper classes in the shaded jar match the tested local JTS candidate.

Did this PR include necessary documentation updates?

No public SQL API or configuration was added. Changing SRID retains the input's geometry structure.

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