Repository navigation
[GH-3146] Write GeoParquet 2.0 files with the Parquet GEOMETRY type - #3553
Merged
Merged
Conversation
…type Setting geoparquet.version to a 2.x version now writes the layout that GeoParquet 2.0 requires. The option used to change only the version string in the file metadata. A geometry column carries the GEOMETRY logical type, with the CRS as a property of the type: absent for OGC:CRS84, authority:code for a CRS with an identifier, inline PROJJSON for one without, and srid:0 for an unknown CRS. The GeoParquet metadata repeats the CRS as PROJJSON. Geometries are stored as ISO WKB, which the logical type requires; the writer used the EWKB flag bit for a Z coordinate. The Parquet library writes geospatial statistics for each row group once the column is annotated, so no covering column is generated. The Spark schema metadata of such a file keeps the native geometry type, as Spark's own writer does, so that Spark 4.2's Parquet reader returns a geometry column. A native Spark geometry type names the SRID of the column. A GeometryUDT column has an SRID on each geometry only, so for now a 2.x write of such a column needs geoparquet.crs. The Parquet library of Spark 3.5 and 4.0 has no GEOMETRY type, and a 2.x write is rejected on the driver there. The default version stays 1.1.0. Any version string that is not 2.x is written as before.
The crs property of a GEOMETRY column was shortened to authority:code whenever the PROJJSON had an id. That form has no place for the version of the id, so IAU_2015:49900, which PROJ writes as authority IAU, code 49900 and version 2015, became IAU:49900. Such a CRS is now written as inline PROJJSON.
…m the version A CRS whose authority is named srid or projjson was shortened to srid:<code> or projjson:<code>, which the Parquet format reads as an SRID or as a reference to a file metadata key. Such a CRS now stays inline PROJJSON. A native geometry column rejects a CRS option whose identifier names a version of its registry. The SRID of the column stands for the current meaning of the code, and the two cannot be compared. The version option decided the layout with the spaces around it ignored but was stored with them. It is now trimmed before it is stored. The tutorial shows the CRS option a 2.x write needs on Spark 4.1 and states what Spark's own Parquet reader returns for a file written from a GeometryUDT column.
jiayuasu
force-pushed
the
feature/geoparquet-2.0-write
branch
from
November 18, 2026 21:05
abd6f96 to
dc80b46
Compare
A native geometry column rejected a CRS option whose id names a version of its registry, but Sedona also takes the SRID from an entry of ids, and a version there was let through. The check is now on the identifier that gives the SRID, in id or in ids. A version on another identifier is no reason to reject the option. The error told the user to remove the version, which makes the write succeed with the same definition. It now asks which CRS the coordinates are in. The tutorial states the rule for native columns in the section on CRS options, since it holds for every GeoParquet version. It no longer lists ISO WKB as a difference from 1.1 files, and it names the columns that the reader cannot load on Spark 4.2.
The tutorial said that such a column fails to load on Spark 4.2. It fails while Sedona infers a native geometry type for it. A schema with Sedona's own geometry type reads the column, and the geometries have SRID 0. The tutorial now says so and shows the schema. The tests read such columns with an explicit schema, from the Parquet fixtures whose CRS cannot be resolved and from a 2.0 file with PROJJSON without an identifier.
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?
[GH-XXX] my subject. Part of Update GeoParquet writer and reader to support GeoParquet 2.0.0 #3146. This is the second PR for GeoParquet 2.0, after [GH-3146] Read Parquet GEOMETRY columns in the GeoParquet reader #3544, so it does not close the issue.What changes were proposed in this PR?
Setting
geoparquet.versionto a 2.x version used to change only the version string in thegeometadata. It now writes the layout GeoParquet 2.0 requires, on Spark 4.1 and 4.2:GEOMETRYlogical type of the Parquet format, and the CRS is a property of that type: absent for OGC:CRS84,authority:codefor a CRS with an identifier, inline PROJJSON for a CRS without one, andsrid:0for an unknown CRS. An identifier that names a version of its registry also keeps inline PROJJSON, becauseauthority:codehas no place for the version: PROJ writesIAU_2015:49900as authorityIAU, code 49900 and version 2015. A CRS whose authority is namedsridorprojjson, in any case, stays inline as well, because the Parquet format readssrid:<number>as an SRID andprojjson:<key>as a reference to a file metadata key. Thegeometadata repeats the CRS as PROJJSON, ornullfor an unknown CRS.geoparquet.coveringstill declares a covering column the user provides.spark.read.parquetreturns a geometry column for a file written from a native column. AGeometryUDTcolumn is recorded there as binary, as in a 1.x file: Spark's own reader returns its WKB on Spark 4.1 and 4.2, and Spark 4.1 can still open the file. The Parquet column has theGEOMETRYtype in both cases, and thegeoparquetreader returns a geometry column for both.Limits of this PR:
1.1.0. A version string whose major part is not2is written as before. The version is stored without the spaces around it.idor an entry ofids, names a version of its registry: the SRID stands for what the code means today, and a code can mean another CRS in another version. This holds for 1.x writes of a native column as well, which have the same two statements of the CRS in the Spark schema metadata and thegeometadata. Native columns need Spark 4.2, which no Sedona release supports yet. The check is on the identifier only. Sedona does not compare the rest of the definition with the SRID and writes it as given, so a definition of another CRS under a plainEPSG:<code>identifier is not detected. AGeometryUDTcolumn (Spark 4.1) has an SRID on each geometry only, so a 2.x write of such a column needsgeoparquet.crsorgeoparquet.crs.<column_name>for now. Taking the CRS from the data is the next PR.geometadata are not affected, and Spark's own writer produces the same statistics.GEOMETRYtype. A 2.x write is rejected on the driver there, with a message that namesgeoparquet.version1.1.0as the alternative.Not in this PR: the default version, CRS inference for
GeometryUDTcolumns, geography columns, and reading on Spark 3.5/4.0.Behaviour of the GeoParquet writer that this PR does not change, for 1.x and 2.x files alike. Each is left to a change of its own:
geoparquet.crsis written as given.bboxof a column in thegeometadata has four values, also for a column with Z, and the spatial filter of the reader reads four values.How was this patch tested?
GeoParquetNativeTypesSuitehas a new block that writes 2.x files and reads the footer back: theGEOMETRYannotation and itscrsfor the default CRS, an EPSG CRS, an unknown CRS and a CRS without an identifier, the CRS taken from the SRID of a native column, the row-group geospatial statistics, ISO WKB for a geometry with Z, thegeometadata, a version given with spaces around it, a 1.1.0 file that keeps plain binary and its covering column, and the rejection on a Parquet library without the geospatial types.ParquetGeospatialTypesTestcovers the mapping from a CRS to thecrsproperty, including an identifier with a registry version and an authority namedsridorprojjson, the rejection of a CRS option on a native column when the identifier that gives the SRID, inidor inids, names a registry version, and the version rule.NativeGeoParquetCrsSuitein thespark-4.2module reads Sedona's 2.0 output with Spark's own Parquet reader for SRID 4326, 3857 and 0. It also reads a 1.1 and a 2.0 file whose CRS is PROJJSON without an identifier: schema inference fails on Spark 4.2, and an explicitGeometryUDTschema returns the geometry with SRID 0.GeoParquetNativeTypesSuitedoes the same for the Parquet fixtures whose CRS cannot be resolved.The GeoParquet suites pass locally on Spark 4.1 / Scala 2.13, Spark 4.2 / Scala 2.13 (including the GeoParquet suites of the
spark-4.2module) and Spark 3.5 / Scala 2.12.Did this PR include necessary documentation updates?