Skip to content

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

Description

@Angel-212

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:

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions