Skip to content

[Python] Add a test for struct-to-struct cast #35408

Open

Description

@schaefer01

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

these are the links for the C++ issue that was solved and closed.

https://issues.apache.org/jira/browse/ARROW-1888
#17882

please do the same for python:

import pyarrow as pa
pa.version
'12.0.0

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

Component(s)

Python

Activity

  1. changed the title [-]cast doesn't work for structure in pyarrow[/-] [+][Python] cast doesn't work for structure in pyarrow[/+] on May 4, 2023
  2. thisisnic commented on Oct 22, 2026

    @thisisnic
    Member

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

  3. AlenkaF commented on Oct 22, 2026

    @AlenkaF
    Member

    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?

  4. changed the title [-][Python] cast doesn't work for structure in pyarrow[/-] [+][Python] Add a test for struct-to-struct cast[/+] on Nov 25, 2026
  5. Abhigyan1805 commented on Dec 3, 2026

    @Abhigyan1805

    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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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