feat: GeoArrow export — GEOGRAPHY/GEOMETRY as geoarrow.wkb#100
Open
jatorre wants to merge 1 commit intoadbc-drivers:mainfrom
Open
feat: GeoArrow export — GEOGRAPHY/GEOMETRY as geoarrow.wkb#100jatorre wants to merge 1 commit intoadbc-drivers:mainfrom
jatorre wants to merge 1 commit intoadbc-drivers:mainfrom
Conversation
Detect GEOGRAPHY/GEOMETRY columns during query execution and tag them with geoarrow.wkb Arrow extension metadata, enabling DuckDB and other Arrow consumers to receive native geometry types with CRS information. How it works: 1. Set GEOGRAPHY/GEOMETRY_OUTPUT_FORMAT=WKB at connection time so geo columns arrive as binary WKB instead of GeoJSON strings 2. Before executing a query, extract the table name and run DESCRIBE TABLE to identify GEOGRAPHY/GEOMETRY columns (catalog metadata is unaffected by the WKB output format setting) 3. Tag identified columns with geoarrow.wkb extension metadata in the Arrow schema — GEOGRAPHY gets CRS "EPSG:4326", GEOMETRY gets no CRS 4. Data flows as binary WKB with zero conversion overhead Note: Snowflake's REST API reports geo columns as "binary" in rowtype metadata when WKB output format is set, losing the original type info. This is why we need the separate DESCRIBE TABLE query. We've reported this to Snowflake. Limitations (documented as TODOs): - GEOMETRY SRID: requires data inspection to determine, same cross-driver issue as adbc-drivers/redshift#2 and adbc-drivers/databricks#350 - Arbitrary queries: only table scans (SELECT ... FROM table) get geoarrow metadata. Complex queries with joins/subqueries don't trigger geo detection. The data is still correct WKB, just without the metadata. Tested end-to-end: DuckDB reads Snowflake GEOGRAPHY as native GEOMETRY with CRS EPSG:4326, and GeoParquet export preserves the type. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Author
|
cc @sfc-gh-obielov — We've reported to Snowflake that the REST API This is why this PR needs an extra |
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.
Summary
Adds geospatial export support: GEOGRAPHY/GEOMETRY columns are automatically tagged with
geoarrow.wkbArrow extension metadata, enabling DuckDB and other Arrow consumers to receive native geometry types.How it works
GEOGRAPHY_OUTPUT_FORMAT=WKBandGEOMETRY_OUTPUT_FORMAT=WKBat connection time so geo columns arrive as binary WKB (not GeoJSON strings)DESCRIBE TABLEto identify GEOGRAPHY/GEOMETRY columns. Catalog metadata correctly reports the original type regardless of output format.ARROW:extension:name = "geoarrow.wkb". GEOGRAPHY gets CRSEPSG:4326(always WGS84). GEOMETRY gets no CRS (see TODOs).identCol).Schema mapping
Why DESCRIBE TABLE?
Snowflake's REST API reports geo columns as
"type": "binary"inrowtyperesponse metadata when WKB output format is set, losing the original type information. BothrowtypeandDESCRIBE RESULTare affected. OnlyDESCRIBE TABLE(catalog metadata) preserves the original type. We've reported this limitation to Snowflake.TODOs
GEOMETRY SRID — Requires inspecting data to determine SRID, which needs first-batch buffering. Same cross-driver challenge as adbc-drivers/redshift#2 and adbc-drivers/databricks#350. Fixed CRS for GEOGRAPHY (always 4326), empty CRS for GEOMETRY.
Arbitrary queries — Currently only table scans (
SELECT ... FROM table) trigger geo detection. Complex queries (joins, subqueries, CTEs) won't get geoarrow metadata. The data is still correct WKB, just without the Arrow extension type annotation.Test results
End-to-end against real Snowflake:
GEOMETRY('EPSG:4326')✓Related
🤖 Generated with Claude Code