dangotbanned opened a new issue, #48344:
URL: https://github.com/apache/arrow/issues/48344
### Describe the bug, including details regarding any error messages,
version, and platform.
This is the inverse of #46355, so I'll continue from there 😅:
### Repro
```py
import pyarrow as pa
table = pa.table({"a": pa.array([]), "b": pa.array([], type=pa.float64())})
array = table.to_struct_array()
print(array)
print(array.type.fields)
pa.Table.from_struct_array(array)
```
### Output
```py
<pyarrow.lib.ChunkedArray object at 0x...>
[
]
[pyarrow.Field<a: null>, pyarrow.Field<b: double>]
./pyarrow/table.pxi:4945, in pyarrow.lib.Table.from_struct_array()
./pyarrow/table.pxi:5032, in pyarrow.lib.Table.from_batches()
ValueError: Must pass schema, or at least one RecordBatch
```
### Workaround
I'm doing quite a lot of version branching here already:
-
https://github.com/narwhals-dev/narwhals/blob/e4f0f83a15808349f2f4970e5549b791671fe601/narwhals/_plan/arrow/series.py#L321-L330
-
https://github.com/narwhals-dev/narwhals/blob/e4f0f83a15808349f2f4970e5549b791671fe601/narwhals/_plan/arrow/functions.py#L337-L334
In short, it looks like:
```py
import pyarrow as pa
table = pa.table({"a": pa.array([]), "b": pa.array([], type=pa.float64())})
array = table.to_struct_array()
from_struct_array = pa.schema(array.type.fields).empty_table()
print(from_struct_array)
```
```py
pyarrow.Table
a: null
b: double
----
a: [0 nulls]
b: [[]]
```
### 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]