zeroshade commented on code in PR #14877:
URL: https://github.com/apache/arrow/pull/14877#discussion_r1043713031
##########
go/arrow/cdata/test/test_export_to_cgo.py:
##########
@@ -161,6 +162,73 @@ def test_batch_roundtrip(self):
del c_schema
del c_batch
+# commented out types can be uncommented after
+# GH-14875 is addressed
+_test_pyarrow_types = [
+ pa.null(),
+ pa.bool_(),
+ pa.int32(),
+ pa.time32("s"),
+ pa.time64("us"),
+ pa.date32(),
+ pa.timestamp("us"),
+ pa.timestamp("us", tz="UTC"),
+ pa.timestamp("us", tz="Europe/Paris"),
+ pa.duration("s"),
+ pa.duration("ms"),
+ pa.duration("us"),
+ pa.duration("ns"),
+ pa.float16(),
+ pa.float32(),
+ pa.float64(),
+ pa.decimal128(19, 4),
+ # pa.string(),
+ # pa.binary(),
+ # pa.binary(10),
+ # pa.large_string(),
+ # pa.large_binary(),
+ pa.list_(pa.int32()),
+ pa.list_(pa.int32(), 2),
+ pa.large_list(pa.uint16()),
+ pa.struct([
+ pa.field("a", pa.int32()),
+ pa.field("b", pa.int8()),
+ # pa.field("c", pa.string()),
+ ]),
+ pa.struct([
+ pa.field("a", pa.int32(), nullable=False),
+ pa.field("b", pa.int8(), nullable=False),
+ # pa.field("c", pa.string()),
+ ]),
+ pa.dictionary(pa.int8(), pa.int64()),
+ # pa.dictionary(pa.int8(), pa.string()),
+ # pa.map_(pa.string(), pa.int32()),
+ pa.map_(pa.int64(), pa.int32()),
+]
+
+def generate_empty_roundrip_test(typ):
+ def test(self):
+ with self.assert_pyarrow_memory_released():
+ a = pa.array([], typ)
+ a._export_to_c(self.ptr_array)
+ typ._export_to_c(self.ptr_schema)
+
+ c_arr = ffi.new("struct ArrowArray*")
+ ptr_arr = int(ffi.cast("uintptr_t", c_arr))
+
+ cgotest.roundtripArray(self.ptr_array, self.ptr_schema, ptr_arr)
+ b = pa.Array._import_from_c(ptr_arr, typ)
+ b.validate(full=True)
+ assert a.to_pylist() == b.to_pylist()
+ assert a.type == b.type
+ del a
+ del b
+ return test
+
if __name__ == '__main__':
+ for typ in _test_pyarrow_types:
Review Comment:
Ah nice! I'll update this to use that. thanks!
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]