Repository navigation
Conversation
…rrays record_batch() already treated list and tuple alike, but RecordBatch.from_arrays was Cython-typed as list, so a tuple of arrays raised TypeError. Match Table.from_arrays and accept any sequence (documented as list or tuple). Closes apache#55418
|
|
Contributor
There was a problem hiding this comment.
🟢 Approval recommended
No active review issues are reported for the tuple-input support change.
No open issues 🎉
What changed in this PR
Fixes #55418 by allowing tuples of arrays in RecordBatch.from_arrays, resolving the tuple-input failure in pa.record_batch() and aligning with Table.from_arrays.
Changes:
- Removes the Cython
listrestriction fromRecordBatch.from_arrays. - Updates parameter documentation and the
record_batch()error message to mention tuples. - Adds a regression test verifying tuple input matches list input.
| File | Description |
|---|---|
python/pyarrow/tests/test_table.py |
Adds regression coverage for constructing a record batch from a tuple of arrays. |
python/pyarrow/table.pxi |
Allows tuple input and updates related documentation and error text. |
Review effort: Balanced
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Rationale for this change
Fixes #55418.
pa.record_batch()acceptslistortupleof arrays, butRecordBatch.from_arrayswas Cython-typed aslist arrays, so a tuple raisedTypeError: Argument 'arrays' has incorrect type (expected list, got tuple).Table.from_arraysalready accepts untyped sequences.What changes are included in this PR?
listtype annotation onRecordBatch.from_arraysso tuples (and other sequences) work, matchingTable.from_arrays.record_batch()TypeError message.pa.record_batch((array,), names=...).Are these changes tested?
test_record_batch_from_tuple_of_arraysinpython/pyarrow/tests/test_table.py.Are there any user-facing changes?
Yes:
pa.record_batch(tuple_of_arrays, ...)andRecordBatch.from_arrays(tuple_of_arrays, ...)now work instead of raising TypeError.AI assistance
Assisted by an AI coding tool for locating the Cython
listannotation and drafting this PR text. I reviewed the call path againstTable.from_arraysand confirmed the failure mode matches issue #55418.