apache / apache/arrow

[Python][C++] Casting a list of struct array with null field results in invalid result

Open
#43,838 1 comment 0 reactions 0 assignees View on GitHub
Component: C++ Component: Python Type: bug
Dominant language
C++
Stars
17.1k
Forks
4.3k
Avg merge
3d 13h
Merged PRs (30d)
88

Description

### Describe the bug, including details regarding any error messages, version, and platform.

OS: MacOS Sonoma 14.6.1
Python: 3.10.14
pyarrow: 17.0.0

Snippet to reproduce:
```python
import pyarrow as pa

fields = [('b', pa.null()),('g', pa.string())]
dtype = pa.list_(pa.struct(fields))
arr = pa.array([[{'b': None, 'g': None}, {'b': None, 'g': 'moo'}]], type=dtype)
carr = pa.chunked_array(arr)
ext_arr = carr.cast(dtype, safe=True)
print(ext_arr) # prints Invalid array but no exception
print(len(ext_arr)) # Len is 1
print(ext_arr[0]) # Raises ArrowIndexError
```

### Component(s)

Python

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.