You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@iceberg.apache.org by "huan233usc (via GitHub)" <gi...@apache.org> on 2026/07/15 20:22:33 UTC

[PR] API: Reject geometry/geography CRS containing type-string delimiters [iceberg]

huan233usc opened a new pull request, #17218:
URL: https://github.com/apache/iceberg/pull/17218

   ## Summary
   
   Reject a geometry/geography CRS that contains a character it could not round-trip through the type string.
   
   `GeometryType` serializes as `geometry(<crs>)` and `GeographyType` as `geography(<crs>, <algorithm>)`. `Types.fromPrimitiveString` parses the CRS out of that string with:
   
   ```
   GEOMETRY_PARAMETERS  = geometry\s*(?:\(\s*([^)]*?)\s*\))?
   GEOGRAPHY_PARAMETERS = geography\s*(?:\(\s*([^,]*?)\s*(?:,\s*(\w*)\s*)?\))?
   ```
   
   so the CRS is read only up to the first `)` (geometry) or the first `,` / `)` (geography). Today the constructors accept any non-empty CRS, so a CRS containing one of those delimiters is written out by `toString()` but silently **truncated** when the type string is parsed back — the schema no longer round-trips.
   
   For example:
   
   ```java
   Types.GeometryType.of("foo)bar").toString()   // "geometry(foo)bar)"
   Types.fromPrimitiveString("geometry(foo)bar)") // parses CRS as "foo" — wrong, silent
   ```
   
   ## Change
   
   Validate the CRS at construction and fail fast with a clear message instead of allowing a value that cannot round-trip:
   
   - `GeometryType` rejects a CRS containing `)`.
   - `GeographyType` rejects a CRS containing `,` or `)` (its type string uses both as delimiters).
   
   A geometry CRS may still contain `,` — geometry's type string has no comma delimiter, so `geometry(foo,bar)` round-trips fine; that case is covered by a positive assertion. Normal CRS values (`EPSG:4326`, `OGC:CRS84`, `srid:<n>`, `projjson:<id>`) are unaffected.
   
   ## Tests
   
   Added `TestTypes.testGeospatialCrsRejectsUnrepresentableCharacters`:
   - `GeometryType.of("foo)bar")` and `GeographyType.of("foo)bar")` / `of("foo,bar")` throw with a clear message.
   - `GeometryType.of("foo,bar")` is accepted and round-trips through `fromPrimitiveString(toString())`.
   
   `:iceberg-api:test`, `spotlessJavaCheck`, `checkstyleMain`, and `checkstyleTest` pass.
   
   This pull request and its description were written by Isaac.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org


Re: [PR] API: Reject geometry/geography CRS containing type-string delimiters [iceberg]

Posted by "huan233usc (via GitHub)" <gi...@apache.org>.
huan233usc closed pull request #17218: API: Reject geometry/geography CRS containing type-string delimiters
URL: https://github.com/apache/iceberg/pull/17218


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org