You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@arrow.apache.org by "dangotbanned (via GitHub)" <gi...@apache.org> on 2025/12/04 22:28:20 UTC

[I] `pa.Table.from_struct_array` fails for an empty array [arrow]

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: issues-unsubscribe@arrow.apache.org.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [I] `pa.Table.from_struct_array` fails for an empty array [arrow]

Posted by "AlenkaF (via GitHub)" <gi...@apache.org>.
AlenkaF commented on issue #48344:
URL: https://github.com/apache/arrow/issues/48344#issuecomment-4766497214

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


-- 
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: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [I] `pa.Table.from_struct_array` fails for an empty array [arrow]

Posted by "AlenkaF (via GitHub)" <gi...@apache.org>.
AlenkaF commented on issue #48344:
URL: https://github.com/apache/arrow/issues/48344#issuecomment-5448729704

   Issue resolved by pull request 49869
   https://github.com/apache/arrow/pull/49869


-- 
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: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [I] `pa.Table.from_struct_array` fails for an empty array [arrow]

Posted by "1fanwang (via GitHub)" <gi...@apache.org>.
1fanwang commented on issue #48344:
URL: https://github.com/apache/arrow/issues/48344#issuecomment-4773565599

   > [@1fanwang](https://github.com/1fanwang) can you add a comment under this issue, so I can assign it to you?
   
   Thanks @AlenkaF 
   PR opened https://github.com/apache/arrow/pull/49869 to address this issue.


-- 
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: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [I] `pa.Table.from_struct_array` fails for an empty array [arrow]

Posted by "AlenkaF (via GitHub)" <gi...@apache.org>.
AlenkaF closed issue #48344: `pa.Table.from_struct_array` fails for an empty array
URL: https://github.com/apache/arrow/issues/48344


-- 
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: issues-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org