Skip to content

bug: reading geospatial data fails with duckdb>=1.5.1 #11978

@knaaptime

Description

@knaaptime

What happened?

when reading geospatial data from a parquet file, ibis throws a schema error. For example this call

con = ibis.duckdb.connect()
t = con.read_parquet('s3://spatial-ucr/census/blocks_2020/11.parquet')

fails with the output below

this is probably related to the recent changes in duckb>=1.5. Yet if i read the data in directly with duckdb (e.g. using:)

import duckdb

con = duckdb.connect()
con.execute("INSTALL spatial;")
con.execute("LOAD spatial;")

query = """
SELECT * FROM read_parquet('s3://spatial-ucr/census/blocks_2020/11.parquet');
"""
df = con.execute(query).fetchdf()

the read executes fine (using duckdb 1.5.1; that call fails on 1.5)

What version of ibis are you using?

12.0.0

What backend(s) are you using, if any?

duckdb

Relevant log output

Traceback (most recent call last):
  File "<python-input-27>", line 2, in <module>
    t = con.read_parquet('s3://spatial-ucr/census/blocks_2020/11.parquet')
  File "/Users/knaaptime/miniforge3/envs/geosnap/lib/python3.14/site-packages/ibis/backends/duckdb/__init__.py", line 840, in read_parquet
    return self.table(table_name)
           ~~~~~~~~~~^^^^^^^^^^^^
  File "/Users/knaaptime/miniforge3/envs/geosnap/lib/python3.14/site-packages/ibis/backends/duckdb/__init__.py", line 286, in table
    table_schema = self.get_schema(name, catalog=catalog, database=database)
  File "/Users/knaaptime/miniforge3/envs/geosnap/lib/python3.14/site-packages/ibis/backends/duckdb/__init__.py", line 341, in get_schema
    name: type_mapper.from_string(typ, nullable=null == "YES")
          ~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/knaaptime/miniforge3/envs/geosnap/lib/python3.14/site-packages/ibis/backends/sql/datatypes.py", line 195, in from_string
    return cls.to_ibis(sgtype, nullable=nullable)
           ~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/knaaptime/miniforge3/envs/geosnap/lib/python3.14/site-packages/ibis/backends/sql/datatypes.py", line 161, in to_ibis
    dtype = method(*typ.expressions, nullable=nullable)
  File "/Users/knaaptime/miniforge3/envs/geosnap/lib/python3.14/site-packages/ibis/backends/sql/datatypes.py", line 360, in _from_sqlglot_GEOMETRY
    typeclass = _geotypes[arg.this.this]
                ~~~~~~~~~^^^^^^^^^^^^^^^
KeyError: '{"$schema":"https://proj.org/schemas/v0.7/projjson.schema.json","type":"GeographicCRS","name":"NAD83","datum":{"type":"GeodeticReferenceFrame","name":"North American Datum 1983","ellipsoid":{"name":"GRS 1980","semi_major_axis":6378137,"inverse_flattening":298.257222101}},"coordinate_system":{"subtype":"ellipsoidal","axis":[{"name":"Geodetic latitude","abbreviation":"Lat","direction":"north","unit":"degree"},{"name":"Geodetic longitude","abbreviation":"Lon","direction":"east","unit":"degree"}]},"scope":"Geodesy.","area":"North America - onshore and offshore: Canada - Alberta; British Columbia; Manitoba; New Brunswick; Newfoundland and Labrador; Northwest Territories; Nova Scotia; Nunavut; Ontario; Prince Edward Island; Quebec; Saskatchewan; Yukon. Puerto Rico. United States (USA) - Alabama; Alaska; Arizona; Arkansas; California; Colorado; Connecticut; Delaware; Florida; Georgia; Hawaii; Idaho; Illinois; Indiana; Iowa; Kansas; Kentucky; Louisiana; Maine; Maryland; Massachusetts; Michigan; Minnesota; Mississippi; Missouri; Montana; Nebraska; Nevada; New Hampshire; New Jersey; New Mexico; New York; North Carolina; North Dakota; Ohio; Oklahoma; Oregon; Pennsylvania; Rhode Island; South Carolina; South Dakota; Tennessee; Texas; Utah; Vermont; Virginia; Washington; West Virginia; Wisconsin; Wyoming. US Virgin Islands. British Virgin Islands.","bbox":{"south_latitude":14.92,"west_longitude":167.65,"north_latitude":86.45,"east_longitude":-40.73},"id":{"authority":"EPSG","code":4269}}'

Code of Conduct

  • I agree to follow this project's Code of Conduct

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugIncorrect behavior inside of ibis

    Type

    No type

    Projects

    Status

    backlog

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions