Skip to content

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

Merged
jiayuasu merged 28 commits into
apache:masterfrom
jiayuasu:fix/declared-geometry-dimensions
Sep 21, 2026
Merged

jiayuasu merged 28 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. Builds on merged #3377 and #3373.

This PR covers serialization and SQL constructors. Copy behavior is in merged #3377; file and adapter readers are in #3378.

org.datasyslab:jts-io-patch:1.21.0-datasyslab-2 is published on Maven Central.

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?

At ea830b85c19095b60457710d968b27c322ff9b54, 354 focused common tests passed against the published org.datasyslab:jts-io-patch:1.21.0-datasyslab-2, covering geometry functions, SRID copying and dimension serialization. The branch includes merged #3377, and its diff contains only the serializer and constructor changes.

Validated the combined Sedona stack at 76f59c947971e06657d01229a4f940863d3e5253 against org.datasyslab:jts-io-patch:1.21.0-datasyslab-2-SNAPSHOT, built from merged JTS commit 1a382cc402f495adf1ea39c4905cafbac491e40f:

  • Full common suite: 1,396 passed.
  • Spark 3.5.0/Scala 2.12 and Spark 4.1.1/Scala 2.13: 324 selected Java and Scala tests passed per profile, covering SQL functions, UDT, collection and reader suites.
  • Stock PySpark 3.5.0 and 4.1.1: 96 native/fallback constructor tests, 144 primitive WKB/EWKB checks, and 18 multipart SQL round-trip checks passed.
  • Spark 4.1 checks exercised two separate executor JVMs. Its bundled JTS 1.20 jar remained unchanged, and ST_GeneratePoints stayed XY.

The published 1.21.0-datasyslab-2 artifact passes 32 isolated-artifact tests against stock JTS 1.20. All nine implementation class files are byte-for-byte identical to the tested snapshot; public downloads and signatures were verified. The full CI matrix and MySQL/Docker constructor suite were not part of these local checks.

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
@jiayuasu
jiayuasu marked this pull request as ready for review September 21, 2026 05:28
@jiayuasu jiayuasu added this to the sedona-2.0.0 milestone Sep 21, 2026
@jiayuasu
jiayuasu merged commit ffbfd69 into apache:master Sep 21, 2026
47 of 56 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.

GeoPandas: leading-null GeoSeries input loses Z dimensions

1 participant