I believe the goal is for it to be supported someday but you are correct that it is not supported today. Please follow https://issues.apache.org/jira/browse/ARROW-1888
On Tue, Oct 26, 2021 at 2:49 PM Wenlei Xie <[email protected]> wrote: > > Hi, > > I am trying to understand the cast behavior for Arrow Array for nested types. > For example, PyArrow supports cast from list(int64) to list(int32): > > >>> import pyarrow as pa > >>> a = pa.array([[1, 2], [3, 4, 5]]) > >>> a.type > ListType(list<item: int64>) > > >>> b = a.cast(pa.list_(pa.int32())) > >>> b.type > ListType(list<item: int32>) > > > However, it's not supported for struct(int64, int64) to struct(int32, int32): > > >>> a = pa.array( [(1, 2), (3, 4)] , type = pa.struct([('f1', pa.int64()) , > >>> ('f2', pa.int64()) ] ) ) > >>> a.type > >>> b = a.cast( pa.struct([('f1', pa.int32()) , ('f2', pa.int32()) ] ) ) > ...... > pyarrow.lib.pyarrow_internal_check_status > File "pyarrow/error.pxi", line 120, in pyarrow.lib.check_status > pyarrow.lib.ArrowNotImplementedError: Unsupported cast from struct<f1: int64, > f2: int64> to struct using function cast_struct > > > I am asking since both casts are supported in ANSI SQL. I am wondering if > CAST for struct is designed not supported in PyArrow? Thanks! > > -- > Best Regards, > Wenlei Xie > > Email: [email protected]
