You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[Python] Add a test for struct-to-struct cast #35408
pa_bytes = pa_result.cast(target_type=pa.uint8())
Traceback (most recent call last):
File "", line 1, in
File "pyarrow/array.pxi", line 935, in pyarrow.lib.Array.cast
File "/usr/local/lib/python3.8/site-packages/pyarrow/compute.py", line 400, in cast
return call_function("cast", [arr], options, memory_pool)
File "pyarrow/_compute.pyx", line 572, in pyarrow._compute.call_function
File "pyarrow/_compute.pyx", line 367, in pyarrow._compute.Function.call
File "pyarrow/error.pxi", line 144, in pyarrow.lib.pyarrow_internal_check_status
File "pyarrow/error.pxi", line 121, in pyarrow.lib.check_status
pyarrow.lib.ArrowNotImplementedError: Unsupported cast from struct<r: int16, i: int16> to uint8 using function cast_uint8
@AlenkaF I'm going through old Type: bug issues. This asks for struct<r: int16, i: int16> to cast to uint8, citing #17882, but that issue implemented struct-to-struct casts (already available from Python via Array.cast()), and a cast from a struct to a primitive type has no defined meaning in Arrow; the reporter can use StructArray.flatten() and cast the fields instead. OK to close as won't fix?
Yes, struct-to-struct cast should work and the issue here, though it mentions the C++ struct-to-struct cast, actually lists a struct to uint8 cast which should use a different approach, as already mentioned in the response.
I'd like to take this and add the Python tests for struct-to-struct casting (rename, reorder, subset, nullability, nested), as discussed above. Could this be assigned to me?
Activity
[-]cast doesn't work for structure in pyarrow[/-][+][Python] cast doesn't work for structure in pyarrow[/+]thisisnic commentedon Oct 22, 2026
@AlenkaF I'm going through old
Type: bugissues. This asks forstruct<r: int16, i: int16>to cast touint8, citing #17882, but that issue implemented struct-to-struct casts (already available from Python viaArray.cast()), and a cast from a struct to a primitive type has no defined meaning in Arrow; the reporter can useStructArray.flatten()and cast the fields instead. OK to close as won't fix?AlenkaF commentedon Oct 22, 2026
Yes, struct-to-struct cast should work and the issue here, though it mentions the C++ struct-to-struct cast, actually lists a struct to uint8 cast which should use a different approach, as already mentioned in the response.
What I am missing though is a short Python test for #17882 (comment) (The PR that implemented the cast added no Python tests: https://github.com/apache/arrow/pull/12248/changes). Maybe worth leaving this open and closing when a test is added?
[-][Python] cast doesn't work for structure in pyarrow[/-][+][Python] Add a test for struct-to-struct cast[/+]Abhigyan1805 commentedon Dec 3, 2026
I'd like to take this and add the Python tests for struct-to-struct casting (rename, reorder, subset, nullability, nested), as discussed above. Could this be assigned to me?