Skip to content

fix: preserve geospatial SRIDs in column type names - #583

Merged
vuanhphung merged 6 commits into
mainfrom
fix/issue-474-geospatial-type-srid
Nov 20, 2026
Merged

vuanhphung merged 6 commits into
mainfrom
fix/issue-474-geospatial-type-srid

Conversation

@vuanhphung

@vuanhphung vuanhphung commented Nov 20, 2026 •

Copy link
Copy Markdown
Collaborator

ColumnType.DatabaseTypeName() drops GEOMETRY/GEOGRAPHY identity and SRIDs on both backends: Thrift exposes the physical STRING type, and the Go kernel mapper discards the full SQL name. Reuse the existing VARIANT override cache and shared Arrow mapper to preserve top-level server SQL names, including GEOMETRY(ANY). Both backends read only Spark:DataType:SqlName; the kernel writes it from manifest type_text alongside type_name. Values, scan types, lengths, raw Arrow schemas and missing/unreadable-schema fallbacks stay unchanged.

Behavior change: With WithEnableGeoSpatialSupport(true) (enableGeoSpatialSupport=true, available since v1.17.0), bare GEOMETRY/GEOGRAPHY metadata becomes SRID-qualified, for example GEOMETRY(0), GEOMETRY(ANY) or GEOGRAPHY(4326). Default string mode changes from STRING to the same qualified names. Match the family before ( when choosing a decoder; EWKT/EWKB values do not change.

Rebased onto main 9d8c6c8 as 2ed88c0, preserving all six commit messages/trailers; range-diff changes only the changelog and nightly test union. Fresh make test: 1,813 total tests, ten existing credential skips, no failures; make lint (zero issues), pure-Go/kernel-tagged builds and arrowscan/root race pass. Live Thrift (3.765s) and SEA text/native (6.122s) pass without skips, also under -race (12.749s total), including inline, empty, NULL-only and 100,000-row CloudFetch results. Exact EWKB assertions cover SRIDs 0/4326/3857 and alternating GEOMETRY(ANY) rows; the earlier wrong-payload negative control and external-module consumer smoke tests remain applicable. The full published-v1.4.0 kernel suite's single capability-test failure (four subcases) and three generated-file formatting differences reproduce on pristine main 9d8c6c8; no unrelated fixes.

Earlier metadata benchmarks use identical corrected kernel fixtures on the original base c1f2469 and this branch, three alternating fresh processes per version and six samples per process (benchstat, 18 samples each). Median base → branch: geography-kernel field 70.17 → 82.07ns; 400-column geo-free schema 28.86 → 23.96µs (-16.97%, zero allocations); cold Thrift metadata 1.660 → 1.787µs (+208B, one allocation/result); cached lookup 10.005 → 8.969ns. Other affected single-field cases add 5.5–9.5ns without allocations. Fixtures include all three actual kernel metadata keys and validate consistency before timing. The rebase changes no approved production code and adds no runtime overhead; these are historical measurements, not rerun comparisons against 9d8c6c8. Live timings use a shared warehouse, not a controlled comparison.

Cross-driver state

Driver State Notes
JDBC Supported Full server type text; EnableGeoSpatialSupport=1 by default, explicit disable reports STRING (DatabricksResultSetMetaData.java:625 @840f3a4).
Python Partial Lowercase families without SRID on both backends (thrift_backend.py:823, kernel/type_mapping.py:176 @087b2bf); native support defaults false.
Go Partial → Supported STRING by default, bare families with native opt-in → full server name/SRID in both modes; values unchanged.
Node.js Not supported Public schema exposes Thrift enum types, not full SQL names (DBSQLOperation.ts:298, KernelOperationBackend.ts:371 @7667e36).
Kernel Supported Writes SqlName from manifest type_text alongside type_name (src/reader/mod.rs:1020 @8877579, since v1.2.0); no upgrade.
ODBC Supported Preserves manifest type text including SRID (kernel_result_set_metadata.cpp:114 @b7fefd8).

JDBC full SQL names are the model; Go deliberately retains existing value representations and reports type identity independently of native opt-in, like its VARIANT handling. Catalog APIs are not applicable to database/sql; #328's native serialization negotiation remains out of scope.

Adversarial review: converged in round 1; all four follow-ups addressed. The bot approved rebased head 2ed88c0 with no findings, including the maintainer-requested EWKB/mixed-SRID coverage. No unresolved review threads.

Fixes #474

This pull request and its description were written by Isaac.

@vuanhphung
vuanhphung marked this pull request as ready for review November 20, 2026 05:08

@oss-reviewer-bot oss-reviewer-bot Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🔀 Cross-reviewed: two independent reviews (Claude Opus 5.5 · GPT-6.1 Sol), checked by a judge model (Claude Sonnet 5.5).

Verdict: 1 Low

Looks good, with 1 low concern. GEOMETRY/GEOGRAPHY SRID names now come through the shared Arrow mapper and the Thrift override path, without changing values, scan types or lengths, and unit and e2e tests cover both backends.

Comment thread internal/arrowscan/coltype.go Resolved
@vuanhphung vuanhphung added the skip-coverage Skip the coverage fan-out for this PR (no tracking issue opened in databricks-driver-test) label Nov 20, 2026

@oss-reviewer-bot oss-reviewer-bot Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🔀 Cross-reviewed: two independent reviews (Claude Opus 5.5 · GPT-6.1 Sol), checked by a judge model (Claude Sonnet 5.5).

Verdict: 1 Nit

Looks good: no findings. Both backends now take geospatial SQL names from Spark:DataType:SqlName. Scan types, lengths and binary-scanner selection stay the same. Unit tests and live E2E tests (registered in the nightly runs) cover SRIDs, fallbacks and concurrent reads.

This overview is Claude Opus 5.5's initial take; GPT-6.1 Sol added findings it doesn't mention — see the findings below.

Other findings

  • ⚪ Nit — The 'geography kernel' benchmark case sets only databricks.type_name and databricks.type_text, not Spark:DataType:SqlName. LogicalGeospatialType reads only SqlName, so the case measures the plain STRING path instead of the geospatial mapping. Add the SqlName key (for example GEOGRAPHY(4326)) to that case's metadata. (Found by GPT-6.1 Sol · confirmed by the judge)

@oss-reviewer-bot oss-reviewer-bot Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🔀 Cross-reviewed: two independent reviews (Claude Opus 5.5 · GPT-6.1 Sol), checked by a judge model (Claude Sonnet 5.5).

✅ No issues identified.

@vuanhphung

Copy link
Copy Markdown
Collaborator Author

Fixed the review-body benchmark nit in 4acfe13: the geography-kernel fixture now includes Spark:DataType:SqlName=GEOGRAPHY(4326) alongside databricks.type_name and databricks.type_text. An untimed setup guard fails without the key and passes with it. Other kernel-shaped PR fixtures already include SqlName or intentionally test missing/conflicting metadata. Production code is unchanged; the refreshed main-versus-branch metadata measurements will replace the previous PR-body numbers.


This comment was generated with GitHub MCP.

@aakash-saravanan-db aakash-saravanan-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.

LGTM.

Non-blocking: could we assert the native EWKB contents, including SRIDs, and add a GEOMETRY(ANY) case containing different per-row SRIDs? That would verify that metadata preserves the declared ANY while each value retains its own SRID.

@vuanhphung

Copy link
Copy Markdown
Collaborator Author

Addressed in 575d9d2 (test-only). The shared live helper now compares exact EWKB bytes for SRIDs 0/4326/3857 and checks that GEOMETRY(ANY) metadata stays ANY while rows alternate SRID=4326;POINT(1 2) and SRID=3857;POINT(3 4), in string/native modes for inline and 100,000-row CloudFetch results. Confirmed live that SQL ST_AsEWKB omits SRID zero, whereas Go native EWKB sets the SRID flag and embeds zero. A wrong odd-row payload fails the new assertion. Live Thrift and kernel text/native pass without skips, including -race; make test (1,722 passed, nine existing credential skips) and make lint pass.


This comment was generated with GitHub MCP.

@oss-reviewer-bot oss-reviewer-bot Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🔀 Cross-reviewed: two independent reviews (Claude Opus 5.5 · GPT-6.1 Sol), checked by a judge model (Claude Sonnet 5.5).

✅ No issues identified.

@vuanhphung
vuanhphung enabled auto-merge November 20, 2026 17:06
@vuanhphung
vuanhphung added this pull request to the merge queue Nov 20, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Nov 20, 2026
vuanhphung and others added 6 commits November 20, 2026 22:59
Signed-off-by: Vu Anh Phung <[email protected]>
Co-authored-by: Isaac <[email protected]>
Signed-off-by: Vu Anh Phung <[email protected]>
Co-authored-by: Isaac <[email protected]>
Thrift sends only Spark:DataType:SqlName, and the kernel writes it from the
manifest type_text in the same block as type_name (src/reader/mod.rs since
v1.2.0), so one key gives the same SRID-qualified names on both backends and
drops the second precedence order that differed from logicalTypeName.

Signed-off-by: Vu Anh Phung <[email protected]>
Co-authored-by: Isaac <[email protected]>
Include Spark:DataType:SqlName in the geography benchmark and reject
incomplete kernel-shaped benchmark fixtures before timing them.

Signed-off-by: Vu Anh Phung <[email protected]>
Co-authored-by: Isaac <[email protected]>
Check exact native geospatial bytes and alternate SRIDs under GEOMETRY(ANY) in inline and CloudFetch results on both backends.

Signed-off-by: Vu Anh Phung <[email protected]>
Co-authored-by: Isaac <[email protected]>
@vuanhphung
vuanhphung force-pushed the fix/issue-474-geospatial-type-srid branch from 575d9d2 to 2ed88c0 Compare November 20, 2026 23:03

@oss-reviewer-bot oss-reviewer-bot Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🔀 Cross-reviewed: two independent reviews (Claude Opus 5.5 · GPT-6.1 Sol), checked by a judge model (Claude Sonnet 5.5).

✅ No issues identified.

@vuanhphung
vuanhphung enabled auto-merge November 20, 2026 23:11
@vuanhphung
vuanhphung added this pull request to the merge queue Nov 20, 2026
Merged via the queue into main with commit bf34893 Nov 20, 2026
14 checks passed
@vuanhphung
vuanhphung deleted the fix/issue-474-geospatial-type-srid branch November 20, 2026 23:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

skip-coverage Skip the coverage fan-out for this PR (no tracking issue opened in databricks-driver-test)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[coverage] Conformance findings: DATATYPE-042

2 participants