Skip to content

[GH-3369] Preserve declared geometry dimensions through serialization - #3374

Draft
jiayuasu wants to merge 27 commits into
apache:masterfrom
jiayuasu:fix/declared-geometry-dimensions
Draft

jiayuasu wants to merge 27 commits into
apache:masterfrom
jiayuasu:fix/declared-geometry-dimensions

Conversation

@jiayuasu

@jiayuasu jiayuasu commented Sep 15, 2026

Copy link
Copy Markdown
Member

Did you read the Contributor Guide?

Yes.

Is this PR related to a ticket?

Closes #3369. Depends on #3377. Builds on merged #3373.

Draft pending review and publication of jts-io-patch:1.21.0-datasyslab-2.

This PR is the serializer and SQL constructor step. Copy behavior is reviewed in #3377; file and adapter readers are in #3378. Review this step after #3377.

The IO2 work is reviewed in JTS #11 (shared layouts/reader) and JTS #12 (writer). Both belong to the same pending release.

WKB output is reviewed separately in #3381.

What changes were proposed in this PR?

Preserve layouts declared in WKB and Sedona geometry buffers, including empty primitive geometries and all-NaN Z/M values. A leading null in a GeoSeries does not change a geometry's layout.

Use IO2's shared declared-sequence types and WKBReader.forDeclaredDimensions() directly. Sedona no longer defines DeclaredCoordinateSequence, DeclaredCoordinateSequenceFactory, or GeometryWkbReader. The JTS geometry factory remains ordinary; its sequence factory preserves declarations on copies without declaring subsequent sized allocations. Ordinary XY operations, including ST_GeneratePoints, remain XY. ST_SetSRID uses the isolated copier through #3377.

Spark's bundled JTS jar stays in place and the Sedona wire format is unchanged. Multipart geometries have one layout header, so conflicting declared component layouts raise the existing heterogeneous-layout error, including XY mixed with a declared empty Z component. Apply ST_ForceCollection before collection to retain individual layouts. Zero-member collections have no coordinate sequence carrying their own declaration.

How was this patch tested?

The core API adaptation passed 100 focused common tests. Validated the combined Sedona stack at 76f59c947971e06657d01229a4f940863d3e5253 against the local, unpublished IO2 candidate:

  • Full common suite: 1,396 passed.
  • Spark 3.5/Scala 2.12 and Spark 4.1/Scala 2.13: 59 selected Java tests and 265 Scala tests passed per profile, including SQL functions, UDT, collection and reader suites. The separate MySQL/Docker constructor suite was not run.
  • Stock PySpark 3.5.0 and 4.1.1: 96 native/fallback constructor cases, four strict dimension probes, and 144 additional WKB output checks passed.
  • Spark 4.1 output checks also passed with two separate executor JVMs and its bundled JTS 1.20 jar unchanged. Fresh shaded jars contain exact candidate class bytes and none of the removed Sedona helpers.

The IO2 candidate passes 80 focused JTS core tests and 27 isolated-artifact tests against stock JTS 1.20. These are local results; the dependency remains unpublished.

Did this PR include necessary documentation updates?

ST_Collect and ST_Collect_Agg document layout requirements and the GeometryCollection alternative. No SQL API or wire-format change.

@jiayuasu
jiayuasu marked this pull request as draft September 16, 2026 07:19
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: leading-null GeoSeries input loses Z dimensions

1 participant