Skip to content

Commit

Permalink
fix(repr): default to pa.binary for all geospatial dtypes (#7817)
Browse files Browse the repository at this point in the history
  • Loading branch information
gforsyth authored Dec 20, 2023
1 parent 49c75a8 commit 066d3fc
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
3 changes: 2 additions & 1 deletion ibis/formats/pyarrow.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
}


Expand Down Expand Up @@ -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)]
Expand Down
17 changes: 17 additions & 0 deletions ibis/formats/tests/test_pyarrow.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()

0 comments on commit 066d3fc

Please sign in to comment.