spenczar opened a new issue, #37004:
URL: https://github.com/apache/arrow/issues/37004
### Describe the bug, including details regarding any error messages,
version, and platform.
I'm taking a table and casting it to its own schema. This should _always_
work, but it errors in a certain case.
(this is deep in some library code - please forgive how strange this
scenario is; just trust me that it really does happen!)
```py
# An extension type which wraps list-of-int32:
class MyExtensionType(pa.PyExtensionType):
def __init__(self):
pa.PyExtensionType.__init__(self, pa.list_(pa.int32()))
def __reduce__(self):
return MyExtensionType, (),
# an array of this type:
ext_array = pa.array([[1, 2, 3]], MyExtensionType())
# Wrap that in a struct:
struct_array = pa.StructArray.from_arrays([ext_array], "x")
# Wrap the struct in a table:
table = pa.Table.from_arrays([struct_array], ["field1"])
```
All of the above is fine, and then:
```python
table.cast(table.schema)
```
Blows up:
```
File
~/.pyenv/versions/3.10.10/envs/general-3.10/lib/python3.10/site-packages/pyarrow/table.pxi:3616,
in pyarrow.lib.Table.cast()
File
~/.pyenv/versions/3.10.10/envs/general-3.10/lib/python3.10/site-packages/pyarrow/table.pxi:3798,
in pyarrow.lib.Table.from_arrays()
File
~/.pyenv/versions/3.10.10/envs/general-3.10/lib/python3.10/site-packages/pyarrow/table.pxi:2962,
in pyarrow.lib.Table.validate()
File
~/.pyenv/versions/3.10.10/envs/general-3.10/lib/python3.10/site-packages/pyarrow/error.pxi:100,
in pyarrow.lib.check_status()
ArrowInvalid: Column 0: In chunk 0: Invalid: Struct child array #0 invalid:
Invalid: Expected 1 child arrays in array of type list<item: int32>, got 0
```
I can print `table` just fine:
```
pyarrow.Table
field1: struct<x: extension<arrow.py_extension_type<MyExtensionType>>>
child 0, x: extension<arrow.py_extension_type<MyExtensionType>>
----
field1: [
-- is_valid: all not null
-- child 0 type: extension<arrow.py_extension_type<MyExtensionType>>
[[1,2,3]]]
```
### Component(s)
Python
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]