sameer727 opened a new pull request, #55820: URL: https://github.com/apache/arrow/pull/55820
### Rationale for this change `pd.concat` of DataFrames with arrow-backed dtypes (e.g. `int32[pyarrow]`) produces chunked arrays inside the pandas columns, so `pa.array()` returns a `ChunkedArray` for those columns and `RecordBatch.from_pandas` fails with `TypeError: Cannot convert pyarrow.lib.ChunkedArray to pyarrow.lib.Array` (#41936). `Table.from_pandas` is unaffected because `Table.from_arrays` accepts chunked arrays. ### What changes are included in this PR? `RecordBatch.from_pandas` now combines the chunked arrays with `ChunkedArray.combine_chunks()` before calling `RecordBatch.from_arrays`. `Table.from_pandas` keeps its chunked columns unchanged (no copying added on that path). ### Are these changes tested? - Added a regression test `test_recordbatch_from_pandas_concatenated_arrow_backed` in `test_pandas.py`, which fails without this change (verified locally against an installed pyarrow 24.0.0 wheel) and passes with it (CI). - The transformation applied by the fix was verified locally on the exact repro: the concatenated column converts to a 2-chunk `ChunkedArray`, and `combine_chunks()` returns a single `Int32Array` with the expected values and type. - The change itself is in Cython, so the final wiring is exercised by the added test in CI. ### Are there any user-facing changes? `RecordBatch.from_pandas` now works for DataFrames containing chunked arrow-backed columns instead of raising `TypeError`. ### Was AI used for this PR? In accordance to the [AI generation guidelines](https://arrow.apache.org/docs/dev/developers/overview.html#ai-generated-code), please disclose below whether and how AI was used in this PR. **PR code and description written by:** - [ ] Human - [x] AI **Reviewed before submission by:** - [ ] Human - [x] AI - [ ] Not reviewed This PR was prepared with an AI coding agent (ZCode) at the direction of the submitter. The bug was reproduced locally with pandas 3.0.2 + pyarrow 24.0.0, the conversion path was traced (`__arrow_array__` returns a single `Array` for a single-chunk column and a `ChunkedArray` after `pd.concat`), and the exact transformation (`combine_chunks()`) was verified locally on the reproduced objects. The Cython wiring itself is exercised by the regression test in CI. * GitHub Issue: #41936 -- 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]
