AlenkaF commented on issue #45880:
URL: https://github.com/apache/arrow/issues/45880#issuecomment-2748182042

   Hi, thank you for opening the issue!
   
   Based on the documentation, as well as the Python and C++ tests, it seems 
that the [`pc. 
list_parent_indices`](https://arrow.apache.org/docs/python/generated/pyarrow.compute.list_parent_indices.html#pyarrow-compute-list-parent-indices)
  method is supported for list-like types but not for struct or map types. This 
is because struct and map arrays have two or more child arrays, meaning the 
method would require different logic and implementation to handle them.
   
   It's worth noting that the distinction between list, struct, and map types 
can be confusing, as they are all considered nested types. In the case of 
PyArrow, the MapArray class actually inherits from ListArray. However, 
according to the C++ Compute documentation, the following type categories are 
defined:
   
   > List-like: List, LargeList, ListView, LargeListView, and sometimes 
FixedSizeList.
   > Nested: List-likes (including FixedSizeList), Struct, Union, and related 
types like Map.
   
   For more details, you can refer to the C++ documentation here: [Apache Arrow 
C++ Compute 
Documentation](https://arrow.apache.org/docs/cpp/compute.html#type-categories).
   
   Now this is all fine, but I would expect a `TypeError`, not a segfault 
(which I can reproduce locally)
   
   To summarize, the issue first requires clarification and update in the 
PyArrow documentation. `pyarrow.MapArray.value_parent_indices` method should 
raise a NotImplementedError or be removed? Also 
[list_parent_indices](https://arrow.apache.org/docs/cpp/compute.html#cpp-compute-vector-structural-transforms)
 kernel should in case of map and struct type return `TypeError` not segfault.
   
   Just for information, this is the log I get locally:
   
   ```
   In [1]: import pyarrow as pa
      ...: print(pa.__version__)
      ...: a = pa.array([dict(a=1,b=2),dict(c=3)],pa.map_(pa.utf8(), 
pa.uint16()))
      ...: print(a.value_parent_indices())
   18.0.0.dev1019+g21c962839
   /Users/alenkafrim/Repos/arrow/cpp/src/arrow/array/array_nested.cc:458:  
Check failed: (data->type->id()) == (expected_type_id) 
   zsh: abort      ipython
   ```


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