Skip to content

pa.Table.from_struct_array fails for an empty array #48344

Closed

Description

@dangotbanned

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

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

<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:

In short, it looks like:

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)
pyarrow.Table
a: null
b: double
----
a: [0 nulls]
b: [[]]

Component(s)

Python

Activity

  1. added 2 commits that reference this issue on Apr 27, 2026
  2. AlenkaF commented on Jun 22, 2026

    @AlenkaF
    Member

    @1fanwang can you add a comment under this issue, so I can assign it to you?

  3. 1fanwang commented on Jun 22, 2026

    @1fanwang
    Contributor

    @1fanwang can you add a comment under this issue, so I can assign it to you?

    Thanks @AlenkaF
    PR opened #49869 to address this issue.

  4. added 3 commits that reference this issue on Aug 23, 2026
  5. added a commit that references this issue on Aug 28, 2026
  6. AlenkaF commented on Aug 28, 2026

    @AlenkaF
    Member

    Issue resolved by pull request 49869
    #49869

  7. added this to the 26.0.0 milestone on Aug 28, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions