Skip to content

[Server] Support geometry and geography in the Iceberg REST catalog - #2371

Open
timothyw553 wants to merge 3 commits into
unitycatalog:mainfrom
timothyw553:stack/geotypes-iceberg
Open

timothyw553 wants to merge 3 commits into
unitycatalog:mainfrom
timothyw553:stack/geotypes-iceberg

Conversation

@timothyw553

@timothyw553 timothyw553 commented Nov 24, 2026 •

Copy link
Copy Markdown
Collaborator

🥞 Stacked PR

Use this link to review incremental changes.


PR Checklist

Description of changes

Maps Iceberg 1.11 geometry(crs) and geography(crs, algorithm) types in IcebergSchemaConverter to ColumnTypeName.GEOMETRY and ColumnTypeName.GEOGRAPHY, formatting type_text and type_json in Delta's form (geometry(<crs>) and geography(<crs>, <algorithm>) with lowercase algorithm). Rejects CRS strings outside <authority>:<code> (including projjson:<property-name> table-property references and inline PROJJSON) with 400 Bad Request so Delta clients are not left with unreadable metadata.

Tested with IcebergSchemaConverterTest (top-level and nested geo types, projjson: and inline PROJJSON rejection) and IcebergRestCatalogTest (create, schema commit, and 400 rejection verifying persisted column metadata).

@timothyw553 timothyw553 left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

two comments on projjson: crs handling and test coverage.

@timothyw553
timothyw553 force-pushed the stack/geotypes-iceberg branch 2 times, most recently from 4303e23 to 930ac5c Compare November 30, 2026 18:59

@timothyw553 timothyw553 left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

conversion logic looks good overall, main question is spark compatibility for some of the crs/algorithm values we still accept. also left one smaller comment on the projjson: error message.

* Delta clients only parse {@code <authority>:<code>}, so a table with another CRS would be
* unreadable to them.
*/
private static String geoTypeString(String geoType, String crs) {

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this validates against delta kernel's grammar, right? i checked spark 4.1–4.3 and epsg:4326, srid:4326, SRID:4326, plus karney/vincenty all still fail to read (and EPSG:4326 fails on 4.1.1). should we clarify whether we're guaranteeing kernel compatibility or spark readability, and either restrict to what spark supports or document the subset?

@timothyw553 timothyw553 Nov 30, 2026 •

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Clarified the Javadoc so it describes the Delta protocol / Kernel grammar that UC validates against rather than a single Spark version's reader subset.

if (crs.toLowerCase(Locale.ROOT).startsWith("projjson:")
|| ColumnUtils.resolveGeoTypeName(geoType) == null) {
throw new BadRequestException(
"Iceberg type %s is not supported by Unity Catalog: the CRS must be <authority>:<code>",

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the error message for projjson:crs_def is a bit misleading since it already matches <authority>:<code>. to my understanding we're rejecting it because iceberg treats it as a table-property reference that wouldn't resolve here, not because of the format. could we split the message and update the comment/tests?

-    if (crs.toLowerCase(Locale.ROOT).startsWith("projjson:")
-        || ColumnUtils.resolveGeoTypeName(geoType) == null) {
+    if (crs.toLowerCase(Locale.ROOT).startsWith("projjson:")) {
+      throw new BadRequestException(
+          "Iceberg type %s is not supported by Unity Catalog: "
+              + "PROJJSON table-property CRS references are not supported",
+          geoType);
+    }
+    if (ColumnUtils.resolveGeoTypeName(geoType) == null) {

@timothyw553 timothyw553 Nov 30, 2026 •

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added an explicit BadRequestException for projjson: CRS references with a clearer error message and updated the unit test to match.

@timothyw553
timothyw553 force-pushed the stack/geotypes-iceberg branch from 930ac5c to 91218fa Compare November 30, 2026 20:12
@timothyw553
timothyw553 marked this pull request as ready for review November 30, 2026 21:36
@yili-db

yili-db commented Nov 30, 2026

Copy link
Copy Markdown
Collaborator

/review

@yili-db yili-db left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[AI Assisted] Approving. The Iceberg mapping matches the 1.11.0 types and the Iceberg spec, and the converter runs before any metadata write.

Non-blocking question: should an Iceberg srid:N CRS map to EPSG:N, or be rejected? Delta uses authority:code forms, so geometry(srid:4326) is not the Delta spelling of 4326.

@timothyw553
timothyw553 force-pushed the stack/geotypes-iceberg branch 3 times, most recently from 390395d to dde86ef Compare December 2, 2026 07:08
@yili-db

yili-db commented Dec 2, 2026

Copy link
Copy Markdown
Collaborator

/review

1 similar comment
@yili-db

yili-db commented Dec 2, 2026

Copy link
Copy Markdown
Collaborator

/review

Add GEOMETRY and GEOGRAPHY to ColumnTypeName in api/all.yaml (appended so existing ordinals stay unchanged).

Widen the ordinal CHECK constraints on uc_functions.data_type and uc_function_params.type_name from 0..21 to 0..23 across H2, PostgreSQL, and MySQL:
- V24 / V26 (SQL): add named CHECK (0..23) constraints on uc_functions and uc_function_params.
- V25 / V27 (Java migrations): look up and drop the old unnamed 0..21 CHECK constraints by clause so upgrades work on both fresh and repaired databases.

Update SchemaMigrator, MigrationStepRulesTest, docs/server/upgrades.md, and schema-effects for all three databases, and add SdkFunctionCRUDTest coverage for GEOMETRY and GEOGRAPHY function parameters and return types.

Signed-off-by: Timothy Wang <[email protected]>
Resolve the geo type strings Delta Kernel parses (geometry[(crs)],
geography[(crs[, algorithm])|(algorithm)]) to GEOMETRY and GEOGRAPHY, and
keep the string as type_text so the CRS and algorithm survive. type_json
already carries it. Without this a Delta table with a geo column is
rejected at create time as an unsupported primitive.

A geography algorithm Delta does not define is rejected with
INVALID_ARGUMENT, as Kernel does; other malformed forms fall through to the
existing unsupported-primitive error.

Signed-off-by: Timothy Wang <[email protected]>
Iceberg 1.11 defines geometry(crs) and geography(crs, algorithm), so map
them to GEOMETRY and GEOGRAPHY instead of rejecting the table, and drop the
comment that said Iceberg has no such types.

type_text and type_json carry the Delta form, geometry(<crs>) and
geography(<crs>, <algorithm>). Iceberg accepts any CRS string, but Delta
clients only parse <authority>:<code>, so another CRS is rejected up front
rather than stored as a type they can't read.

Signed-off-by: Timothy Wang <[email protected]>
@timothyw553
timothyw553 force-pushed the stack/geotypes-iceberg branch from dde86ef to 4bed744 Compare December 2, 2026 19:27

This branch has not been deployed

No deployments
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.

2 participants