Skip to content

fix(go): geo type auto-detect should not require edges:spherical for GEOGRAPHY#167

Open
jatorre wants to merge 1 commit into
adbc-drivers:mainfrom
jatorre:fix/geo-type-auto-detect-4326
Open

fix(go): geo type auto-detect should not require edges:spherical for GEOGRAPHY#167
jatorre wants to merge 1 commit into
adbc-drivers:mainfrom
jatorre:fix/geo-type-auto-detect-4326

Conversation

@jatorre

@jatorre jatorre commented Jul 4, 2026

Copy link
Copy Markdown
Contributor

resolveGeoType's own doc comment says "missing CRS, EPSG:4326, or unparsable CRS stays GEOGRAPHY", and docs/snowflake.md's option table described detection differently again — but the implementation required edges == "spherical" in addition to SRID 4326 before choosing GEOGRAPHY.

Most GeoArrow producers emit a crs but no edges field (DuckDB's spatial extension and GeoPandas among them), so in practice every WGS84 column ingested through auto-detect silently landed as GEOMETRY. We hit this in CARTO's integration suite when moving from the pre-merge #117 branch to go/v1.11.0: same import, GEOGRAPHY became GEOMETRY.

This aligns the code with the documented contract:

  • SRID 4326 or no CRS → GEOGRAPHY
  • any other SRID → GEOMETRY (SRID survives the round trip via ST_SETSRID)
  • edges:spherical with a non-4326 SRID → still an error (unchanged)
  • explicit adbc.snowflake.statement.ingest_geo_type → unchanged, pins all columns

Updated TestResolveGeoType and the option docs to match. The two auto-detect validation txtcases are unaffected (the GEOGRAPHY one uses 4326+spherical, the GEOMETRY one uses EPSG:2029).

https://claude.ai/code/session_01Y3xqZXWrx9qXdPNXBzNxa2

…GEOGRAPHY

resolveGeoType's documented contract (and the original adbc-drivers#117 semantics) says
'missing CRS, EPSG:4326, or unparsable CRS stays GEOGRAPHY', but the code
required edges == "spherical" as well. Most GeoArrow producers (DuckDB,
GeoPandas) emit a crs with no edges field, so all WGS84 data silently
demoted to GEOMETRY on ingest.

Auto-detect now resolves: SRID 4326 or no CRS -> GEOGRAPHY; any other
SRID -> GEOMETRY (SRID survives the round trip); edges:spherical with a
non-4326 SRID remains an error. Explicit ingest_geo_type is unchanged.

Claude-Session: https://claude.ai/code/session_01Y3xqZXWrx9qXdPNXBzNxa2
@lidavidm

lidavidm commented Jul 5, 2026

Copy link
Copy Markdown
Contributor

CC @paleolimbot but my understanding is that this was semantically required

@paleolimbot

Copy link
Copy Markdown
Contributor

CC paleolimbot but my understanding is that this was semantically required

Yes, this is my fault 🙂 .

DuckDB's spatial extension and GeoPandas among them

Both of these only support "geometry", so "geometry" is the type that should be automatically chosen (although it's fair that you'd want to override that choice if you want to insert into a Snowflake geography, which I believe is possible). Specifically, these tools treat edges as Cartesian planar edges regardless of CRS, so they map to the Snowflake version of that.

The only tools I know about that support the union of Geography, Geometry, and GeoArrow are SedonaDB and PyArrow (after GeoArrow extension types are loaded via import geoarrow.pyarrow). PyArrow will emit "edges": "spherical" when reading a GEOGRAPHY type from a Parquet file; SedonaDB has fairly complete support and is a few functions away from BigQuery parity (ST_TessellateGeom(), ST_TessellateGeog() , ST_ToGeometry() and ST_ToGeography() can get you between them nicely).

doc comment says "missing CRS, EPSG:4326, or unparsable CRS stays GEOGRAPHY"

Probably the fix here is to fix the comment, which is outdated.

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