Skip to content

Commit 7d01dea

Browse files
committed
maybe fix for old pyarrows
1 parent d89b358 commit 7d01dea

2 files changed

Lines changed: 20 additions & 4 deletions

File tree

geoarrow-pyarrow/tests/test_pyarrow.py

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -124,10 +124,6 @@ def test_array():
124124
assert array.type == ga.large_wkt()
125125
assert array.type.storage_type == pa.large_utf8()
126126

127-
array = ga.array(["POINT (30 10)"], ga.wkt_view())
128-
assert array.type == ga.wkt_view()
129-
assert array.type.storage_type == pa.string_view()
130-
131127
array = ga.array([wkb_item], ga.wkb())
132128
assert array.type == ga.wkb()
133129
assert array.type.storage_type == pa.binary()
@@ -136,6 +132,20 @@ def test_array():
136132
assert array.type == ga.large_wkb()
137133
assert array.type.storage_type == pa.large_binary()
138134

135+
136+
def test_array_view_types():
137+
# This one requires pyarrow >= 18, because that's when the necessary
138+
# cast() was added.
139+
try:
140+
pa.array(["foofy"]).cast(pa.string_view())
141+
except pa.lib.ArrowNotImplementedError:
142+
pytest.skip("ga.array() with view types requires pyarrow >= 18.0.0")
143+
144+
array = ga.array(["POINT (30 10)"], ga.wkt_view())
145+
assert array.type == ga.wkt_view()
146+
assert array.type.storage_type == pa.string_view()
147+
148+
wkb_item = b"\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x3e\x40\x00\x00\x00\x00\x00\x00\x24\x40"
139149
array = ga.array([wkb_item], ga.wkb_view())
140150
assert array.type == ga.wkb_view()
141151
assert array.type.storage_type == pa.binary_view()

geoarrow-types/tests/test_type_pyarrow.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -472,6 +472,12 @@ def test_multipolygon_array_from_geobuffers():
472472
],
473473
)
474474
def test_roundtrip_extension_type(spec):
475+
if not hasattr(pa, "binary_view") and spec.encoding in (
476+
gt.Encoding.WKB_VIEW,
477+
gt.Encoding.WKT_VIEW,
478+
):
479+
pytest.skip("binary_view/string_view requires pyarrow >= 14")
480+
475481
extension_type = type_pyarrow.extension_type(spec)
476482
serialized = extension_type.__arrow_ext_serialize__()
477483
extension_type2 = type_pyarrow._deserialize_storage(

0 commit comments

Comments
 (0)