Skip to content

Commit

Permalink
fix(duckdb): use simple GEOMETRY type for all geospatial data (#10324) (
Browse files Browse the repository at this point in the history
#10333)

Co-authored-by: Phillip Cloud <[email protected]>
  • Loading branch information
anjakefala and cpcloud authored Oct 24, 2024
1 parent fbf214d commit 0b98112
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
12 changes: 12 additions & 0 deletions ibis/backends/duckdb/tests/test_geospatial.py
Original file line number Diff line number Diff line change
Expand Up @@ -562,3 +562,15 @@ def test_to_geo_geom_only(con, driver, tmp_path):
dread = con.read_geo(out)

assert dread.count().execute() == 2


def test_cache_geometry(con, monkeypatch):
# ibis issue #10324

# monkeypatching is necessary to ensure the correct backend is used for
# caching
monkeypatch.setattr(ibis.options, "default_backend", con)
data = ibis.memtable({"x": [1], "y": [2]})
data = data.select(geom=data.x.point(data.y)).cache()
result = data.execute()
assert result.at[0, "geom"] == shapely.Point(1, 2)
4 changes: 4 additions & 0 deletions ibis/backends/sql/datatypes.py
Original file line number Diff line number Diff line change
Expand Up @@ -624,6 +624,10 @@ def _from_ibis_GeoSpatial(cls, dtype: dt.GeoSpatial):
), "DuckDB only supports geometry types; geography types are not supported"
return sge.DataType(this=typecode.GEOMETRY)

_from_ibis_Point = _from_ibis_LineString = _from_ibis_Polygon = (
_from_ibis_MultiLineString
) = _from_ibis_MultiPoint = _from_ibis_MultiPolygon = _from_ibis_GeoSpatial


class TrinoType(SqlglotType):
dialect = "trino"
Expand Down

0 comments on commit 0b98112

Please sign in to comment.