judahrand commented on code in PR #38520:
URL: https://github.com/apache/arrow/pull/38520#discussion_r1423745301
##########
python/pyarrow/tests/test_table.py:
##########
@@ -878,6 +878,85 @@ def test_recordbatch_from_struct_array():
))
+def test_recordbatch_to_struct_array():
+ batch = pa.RecordBatch.from_arrays(
+ [
+ pa.array([1, None], type=pa.int32()),
+ pa.array([None, 1.0], type=pa.float32()),
+ ], ["ints", "floats"]
+ )
+ result = batch.to_struct_array()
+ assert result.equals(pa.array(
+ [{"ints": 1}, {"floats": 1.0}],
+ type=pa.struct([("ints", pa.int32()), ("floats", pa.float32())]),
+ ))
+
+
+def test_table_from_struct_array_invalid():
+ with pytest.raises(
+ TypeError,
+ match="Argument 'struct_array' has incorrect type "
+ "(expected pyarrow.lib.StructArray, got pyarrow.lib.Int64Array)",
Review Comment:
I'm sorry, that's embarrassing! I didn't loop around to get my `pyarrow` dev
environment working again so was making blind changes but I should have caught
this!
--
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]