jorisvandenbossche commented on a change in pull request #11765:
URL: https://github.com/apache/arrow/pull/11765#discussion_r757042265



##########
File path: python/pyarrow/tests/test_compute.py
##########
@@ -2208,6 +2208,22 @@ def test_make_struct():
         pc.make_struct(field_names=['one', 'two'])
 
 
+def test_struct_fields_options():
+    a = pa.array([4, 5, 6], type=pa.int64())
+    b = pa.array(["bar", None, ""])
+    c = pa.StructArray.from_arrays([a, b], ["a", "b"])
+    arr = pa.StructArray.from_arrays([a, c], ["a", "c"])
+
+    assert pc.struct_field(arr,
+                           indices=[1, 1]) == pa.array(["bar", None, ""])
+    assert pc.struct_field(arr,
+                           indices=[0]) == pa.array([4, 5, 6], type=pa.int64())
+    assert pc.struct_field(arr, indices=[]) == arr
+
+    # TODO: https://issues.apache.org/jira/browse/ARROW-14853
+    # assert pc.struct_field(arr) == arr
+

Review comment:
       Can you maybe add one additional test ensuring you get a TypeError if 
you do eg `pc.struct_field(arr, indices=['a'])`? (so with string name instead 
of integer index)




-- 
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]


Reply via email to