From 066d3fc02f47a358b063c271ca6aa0f182d5723e Mon Sep 17 00:00:00 2001 From: Gil Forsyth Date: Wed, 20 Dec 2023 14:14:02 -0500 Subject: [PATCH] fix(repr): default to pa.binary for all geospatial dtypes (#7817) --- ibis/formats/pyarrow.py | 3 ++- ibis/formats/tests/test_pyarrow.py | 17 +++++++++++++++++ 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/ibis/formats/pyarrow.py b/ibis/formats/pyarrow.py index 61b57cb7f460..993ce20fe703 100644 --- a/ibis/formats/pyarrow.py +++ b/ibis/formats/pyarrow.py @@ -90,7 +90,6 @@ def __arrow_ext_scalar_class__(self): dt.Unknown: pa.string(), dt.MACADDR: pa.string(), dt.INET: pa.string(), - dt.GeoSpatial: pa.binary(), } @@ -191,6 +190,8 @@ def from_ibis(cls, dtype: dt.DataType) -> pa.DataType: return pa.map_(key_field, value_field, keys_sorted=False) elif dtype.is_json(): return PYARROW_JSON_TYPE + elif dtype.is_geospatial(): + return pa.binary() else: try: return _to_pyarrow_types[type(dtype)] diff --git a/ibis/formats/tests/test_pyarrow.py b/ibis/formats/tests/test_pyarrow.py index 1bfcb52ca252..c94ce18866f2 100644 --- a/ibis/formats/tests/test_pyarrow.py +++ b/ibis/formats/tests/test_pyarrow.py @@ -159,3 +159,20 @@ def test_schema_roundtrip(pyarrow_schema): def test_unknown_dtype_gets_converted_to_string(): assert PyArrowType.from_ibis(dt.unknown) == pa.string() + + +@pytest.mark.parametrize( + "ibis_type", + [ + pytest.param(dt.geometry, id="geometry"), + pytest.param(dt.geography, id="geography"), + pytest.param(dt.point, id="point"), + pytest.param(dt.linestring, id="linestring"), + pytest.param(dt.polygon, id="polygon"), + pytest.param(dt.multilinestring, id="multilinestring"), + pytest.param(dt.multipoint, id="multipoint"), + pytest.param(dt.multipolygon, id="multipolygon"), + ], +) +def test_geo_gets_converted_to_binary(ibis_type): + assert PyArrowType.from_ibis(ibis_type) == pa.binary()