Skip to content

GH-55418: [Python] Accept tuple of arrays in RecordBatch.from_arrays - #55422

Open
ump45nose wants to merge 1 commit into
apache:mainfrom
ump45nose:fix/55418-record-batch-tuple
Open

ump45nose wants to merge 1 commit into
apache:mainfrom
ump45nose:fix/55418-record-batch-tuple

Conversation

@ump45nose

Copy link
Copy Markdown

Rationale for this change

Fixes #55418.

pa.record_batch() accepts list or tuple of arrays, but RecordBatch.from_arrays was Cython-typed as list arrays, so a tuple raised TypeError: Argument 'arrays' has incorrect type (expected list, got tuple). Table.from_arrays already accepts untyped sequences.

What changes are included in this PR?

  • Drop the Cython list type annotation on RecordBatch.from_arrays so tuples (and other sequences) work, matching Table.from_arrays.
  • Document parameters as list or tuple; clarify the record_batch() TypeError message.
  • Add a unit test for pa.record_batch((array,), names=...).

Are these changes tested?

  • Added test_record_batch_from_tuple_of_arrays in python/pyarrow/tests/test_table.py.
  • Full pyarrow rebuild/tests were not run in this environment (Cython extension); CI should cover it.

Are there any user-facing changes?

Yes: pa.record_batch(tuple_of_arrays, ...) and RecordBatch.from_arrays(tuple_of_arrays, ...) now work instead of raising TypeError.

AI assistance

Assisted by an AI coding tool for locating the Cython list annotation and drafting this PR text. I reviewed the call path against Table.from_arrays and confirmed the failure mode matches issue #55418.

…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
Copilot AI balanced review requested due to automatic review settings November 5, 2026 23:52
@github-actions

github-actions Bot commented Nov 5, 2026

Copy link
Copy Markdown

⚠️ GitHub issue #55418 has been automatically assigned in GitHub to PR creator.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 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 list restriction from RecordBatch.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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Python] pa.record_batch raises TypeError for tuple data

2 participants