Skip to content

[CLI/UI/Docs] Support and document geometry and geography columns - #2373

Open
timothyw553 wants to merge 5 commits into
unitycatalog:mainfrom
timothyw553:stack/geotypes-cli
Open

timothyw553 wants to merge 5 commits into
unitycatalog:mainfrom
timothyw553:stack/geotypes-cli

Conversation

@timothyw553

@timothyw553 timothyw553 commented Nov 24, 2026 •

Copy link
Copy Markdown
Collaborator

🥞 Stacked PR

Use this link to review incremental changes.


PR Checklist

  • A description of the changes is added to the description of this PR.
  • If there is a related issue, make sure it is linked to this PR.
  • If you've fixed a bug or added code that should be tested, add tests!
  • If you've added or modified a feature, documentation in docs is updated

Description of changes

  • CLI: Accepts GEOMETRY and GEOGRAPHY (with optional CRS and algorithm) in bin/uc table create --columns, preserving them in type_text and type_json. When reading a Delta table with bin/uc table read, deserializes geo columns' Kernel types from type_json and prints WKB bytes as 0x-prefixed hex instead of throwing UnsupportedOperationException.
  • UI (ui-new): Adds COLUMN_TYPE_NAME_GEOMETRY and COLUMN_TYPE_NAME_GEOGRAPHY to ui-new/proto/uc/v1/common.proto and maps "GEOMETRY" / "GEOGRAPHY" in ui-new/server/src/mapping.rs so geo columns do not come back as UNSPECIFIED.
  • Docs: Documents GEOMETRY and GEOGRAPHY columns in docs/usage/cli.md, docs/usage/tables/deltalake.md, and docs/usage/tables/formats.md, including --columns syntax, defaults (OGC:CRS84, spherical), supported algorithms, WKB hex output on read, and Spark/Delta runtime requirements (Spark 4.1+, spark.databricks.delta.geo.preview.enabled=true, and Spark 4.2+ for Parquet writes).

Tested with CLI column-parsing, Kernel type-deserialization, WKB hex-formatting, and table-creation unit tests, plus buf lint, buf build, and ui-new/web tests locally (ui-new/server Rust tests still need a cargo test run where crates.io is reachable).

}

#[test]
fn maps_geo_column_types() {

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.

awesome. Thanks for adding these in here.

@newfront newfront 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.

I looked over the changes to ui-new. These look great.

@yili-db

yili-db commented Dec 2, 2026

Copy link
Copy Markdown
Collaborator

/review

@timothyw553
timothyw553 force-pushed the stack/geotypes-cli branch 2 times, most recently from 8922814 to 8d122f4 Compare December 2, 2026 07:08
@yili-db

yili-db commented Dec 2, 2026

Copy link
Copy Markdown
Collaborator

/review

@yili-db

yili-db commented Dec 2, 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] Review of this PR's own commit, 8d122f4. It is stacked on #2369 to #2372. Those are unchanged since their reviews, so only this commit was reviewed.

Findings:

  • Geo CRS and algorithm in --columns can be silently dropped (inline on CliUtils.java).
  • The legacy UI generated enum is still not regenerated. ui/src/types/api/catalog.gen.ts has no GEOMETRY or GEOGRAPHY, and #2375 (the UI PR) is closed, so no open PR covers it. Could it be regenerated here or in an open PR?
  • Follow-up: add a CLI create test for a geo Delta table. The create path is not covered end to end. Delta Kernel 4.4.1 appears to enable the geospatial feature from the schema (checked by reading the class), so the test would confirm it.
  • Nit: bin/uc table create --help (CliParams.java, COLUMNS text) does not list GEOMETRY or GEOGRAPHY.
  • Nit: the CLI does not validate the CRS or algorithm, so a bad value is only rejected later by the server. Validating the <authority>:<code> form and GeographyType.VALID_ALGORITHMS in parseColumns would fail earlier.

String precisionAndScale = setPrecisionAndScale(columnInfo, typeName, params);
if (isGeoType(typeName) && params != null) {
// GEOMETRY(<crs>) or GEOGRAPHY(<crs>[, <algorithm>]): keep the CRS and algorithm.
precisionAndScale = "(" + params.trim().replaceAll("\\s*,\\s*", ", ") + ")";

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] This keeps the parsed CRS or algorithm only when params is non-null, but the column pattern only captures parameters that start right after the type name (GEOMETRY(). g GEOMETRY (EPSG:3857), g GEOMETRY(EPSG:3857 and g GEOMETRY() all reach here with params == null, so the column is stored as bare geometry (the default OGC:CRS84), and g GEOGRAPHY (EPSG:4326, karney) loses its algorithm. The pattern was reproduced with a standalone Java snippet. Could we accept the same \s*\( form that DECIMAL gets, and fail on parameters that are not consumed?

String precisionAndScale = setPrecisionAndScale(columnInfo, typeName, params);
if (isGeoType(typeName) && params != null) {
// GEOMETRY(<crs>) or GEOGRAPHY(<crs>[, <algorithm>]): keep the CRS and algorithm.
precisionAndScale = "(" + params.trim().replaceAll("\\s*,\\s*", ", ") + ")";

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] The geo parameters are put into type_json without escaping. typeJson is built with String.format around this value, so a " or \ in a CRS or algorithm produces invalid JSON. Found by reading the code, not reproduced. Could the JSON be built with a serializer, or could the parameters be rejected unless they match the CRS and algorithm forms?

Comment thread docs/usage/cli.md
- Delta Lake support for geospatial types is a preview feature that is off by default. Enable it in the Spark session with `spark.databricks.delta.geo.preview.enabled=true`.
- Writing geo values to Parquet files needs Spark 4.2 or later. On Spark 4.1 a geo table can be created and read as a schema, but inserting rows fails.
- `bin/uc table read` shows a geo value as its well-known binary (WKB) in hex.
- The server accepts Delta's `geometry(<crs>)` and `geography(<crs>, <algorithm>)` type strings, and stores them as given.

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] type_json keeps the Delta type the user supplied, but the server stores type_text in canonical form (whitespace is trimmed and the geography algorithm is lowercased). Could this say that instead of "stores them as given"?

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]>
Map Spark's geometry and geography types to GEOMETRY and GEOGRAPHY when
creating a table, through a GeoTypes shim that is a no-op on Spark 4.0,
which has neither type.

Load a table whose geo column was stored in Delta's form, such as
geometry(OGC:CRS84): Spark's DDL parser rejects that, but its JSON parser
reads it, so such a column is read from type_json.

Tests: unit tests for both mappings, a create-and-load test for managed Delta
tables on Spark 4.1+, and geo columns in the type matrix on Spark 4.2+, where
the Parquet writer can write them. Delta's geo preview flag is set in the test
sessions only.

Signed-off-by: Timothy Wang <[email protected]>

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.

3 participants