Copilot commented on code in PR #49869:
URL: https://github.com/apache/arrow/pull/49869#discussion_r3450880944
##########
python/pyarrow/table.pxi:
##########
@@ -4915,10 +4915,13 @@ cdef class Table(_Tabular):
if isinstance(struct_array, Array):
return
Table.from_batches([RecordBatch.from_struct_array(struct_array)])
else:
- return Table.from_batches([
- RecordBatch.from_struct_array(chunk)
- for chunk in struct_array.chunks
- ])
+ return Table.from_batches(
+ [
+ RecordBatch.from_struct_array(chunk)
+ for chunk in struct_array.chunks
+ ],
+ schema=schema(struct_array.type.fields),
+ )
Review Comment:
`schema(struct_array.type.fields)` will raise `AttributeError` for a
zero-chunk `ChunkedArray` whose type isn't a struct (e.g.,
`pa.chunked_array([], type=pa.int32())`). Previously, non-struct chunked inputs
would raise a `TypeError` from `RecordBatch.from_struct_array`; with zero
chunks, this change can regress to an `AttributeError` with a less helpful
message. Consider guarding the schema construction and raising a consistent
`TypeError` when the input type isn't struct.
--
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]