[GH-3150] Preserve GeoParquet CRS metadata - #3151
Merged
jiayuasu merged 2 commits intoJul 23, 2026
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR fixes GeoParquet CRS handling so that PROJJSON CRS metadata round-trips without mutating nested PROJJSON keys, and SRID extraction can succeed based solely on the declared top-level PROJJSON id (without requiring a fully-instantiable CRS/projection).
Changes:
- Preserve CRS PROJJSON exactly as stored in GeoParquet metadata by restoring the raw
crsJValue after camelizing the outer GeoParquet structures. - Rework SRID extraction to read
id.authority+id.codedirectly (supporting positive numeric and numeric-string EPSG codes; mappingOGC:CRS84to 4326; invalid/unsupported identifiers to 0). - Add regression tests covering PROJJSON preservation and SRID extraction for incomplete CRS objects and invalid/string EPSG codes.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| spark/common/src/main/scala/org/apache/spark/sql/execution/datasources/geoparquet/GeoParquetMetaData.scala | Restores raw crs after camelization and simplifies SRID extraction to read PROJJSON id directly. |
| spark/common/src/test/scala/org/apache/sedona/sql/geoparquetIOTests.scala | Adds regression tests for PROJJSON key preservation and expanded SRID extraction scenarios. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
jiayuasu
marked this pull request as ready for review
July 23, 2026 08:16
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Did you read the Contributor Guide?
Is this PR related to a ticket?
[SEDONA-XXX] my subject.[GH-XXX] my subject. Closes GeoParquet CRS parsing mutates PROJJSON keys #3150[DOCS] my subject[CI] my subjectWhat changes were proposed in this PR?
Preserve GeoParquet CRS metadata exactly as it appears in the nested PROJJSON object when parsing or serializing the
geometadata. The outer GeoParquet structure still uses the case conversion required by its case classes, but the rawcrssubtree is restored afterward so standard keys and user-provided extensions are not changed in either direction.Extract a geometry SRID directly from declared top-level PROJJSON identifiers instead of constructing a projection solely to call
toAuthority(). Both the singularidand pluralidsforms are supported. Positive numeric and numeric-string EPSG codes are accepted,OGC:CRS84maps to SRID 4326 case-insensitively, and invalid or unsupported identifiers map to SRID 0.The root cause was recursive key conversion combined with requiring a complete executable CRS definition for identifier extraction. This could make GeoParquet files with non-default CRS metadata fail to round trip with the current proj4sedona parser, expose mutated CRS JSON through metadata queries, or lose their SRID.
This also improves the read path.
extractSridFromCrsruns fromGeoParquetSchemaConverterfor each geometry column in each file footer; direct JSON field reads avoid repeatedly parsing PROJJSON, resolving registries and datums, and constructing full projection objects during multi-file scans.The fix is user-visible through the
geoparquet.metadatadata source in all four Spark shims. They shareparseKeyValueMetaData, so renderedcolumnMetadata.crsvalues now retain the original PROJJSON keys instead of exposing camelized JSON.When PROJJSON contains neither a recognized top-level
idnor a recognized entry inids, this change deliberately returns SRID 0 rather than attempting parameter-based authority inference through proj4sedona. Sedona-written GeoParquet includes an identifier, while preserving the raw CRS object still lets callers inspect identifier-free third-party metadata.Regression tests cover exact PROJJSON preservation on write and read, incomplete ID-bearing CRS objects, plural identifiers, case-insensitive OGC identifiers, numeric-string EPSG codes, and invalid codes.
How was this patch tested?
geoparquetIOTestswith the released proj4sedona 0.1.2 dependency: 52 tests passed.geoparquetIOTestswith the current proj4sedona main branch installed as a local snapshot: 52 tests passed.CRSTransformProj4Test,geoparquetIOTests, andnetcdfMetadataTesttogether with that snapshot: 157 tests passed.Did this PR include necessary documentation updates?
vX.Y.Zformat.