[SPARK-46776][PYTHON] Support pa.ChunkedArray columns in createDataFrame from pandas#56157
Closed
Yicong-Huang wants to merge 1 commit into
Closed
[SPARK-46776][PYTHON] Support pa.ChunkedArray columns in createDataFrame from pandas#56157Yicong-Huang wants to merge 1 commit into
Yicong-Huang wants to merge 1 commit into
Conversation
Contributor
Author
HyukjinKwon
approved these changes
May 28, 2026
Yicong-Huang
added a commit
that referenced
this pull request
May 28, 2026
…ame from pandas ### What changes were proposed in this pull request? `pa.Array.from_pandas` may return a `pa.ChunkedArray` (e.g. for `string[pyarrow]` dtype, or string data over 2 GB), which `pa.RecordBatch.from_arrays` rejects. Route the conversion through `pa.Table.from_arrays(...).to_batches()` instead, which accepts both `Array` and `ChunkedArray` and emits zero-copy `RecordBatch`es aligned on a common chunk boundary. ### Why are the changes needed? Fix `createDataFrame` from pandas raising `TypeError: Cannot convert pyarrow.lib.ChunkedArray to pyarrow.lib.Array`. See [SPARK-46776](https://issues.apache.org/jira/browse/SPARK-46776). ### Does this PR introduce _any_ user-facing change? Yes. `createDataFrame(pandas_df)` no longer raises when a column is backed by a multi-chunk pyarrow array. ### How was this patch tested? New test `ArrowTestsMixin.test_createDataFrame_pandas_chunked_array_backed`, exercised on both classic and Spark Connect paths via the parity suite. ### Was this patch authored or co-authored using generative AI tooling? No Closes #56157 from Yicong-Huang/SPARK-46776. Authored-by: Yicong Huang <17627829+Yicong-Huang@users.noreply.github.com> Signed-off-by: Yicong-Huang <17627829+Yicong-Huang@users.noreply.github.com> (cherry picked from commit 2f4ed64) Signed-off-by: Yicong-Huang <17627829+Yicong-Huang@users.noreply.github.com>
Contributor
Author
|
Merged to master and branch-4.x. |
Contributor
|
late lgtm |
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.
What changes were proposed in this pull request?
pa.Array.from_pandasmay return apa.ChunkedArray(e.g. forstring[pyarrow]dtype, or string data over 2 GB), whichpa.RecordBatch.from_arraysrejects. Route the conversion throughpa.Table.from_arrays(...).to_batches()instead, which accepts bothArrayandChunkedArrayand emits zero-copyRecordBatches aligned on a common chunk boundary.Why are the changes needed?
Fix
createDataFramefrom pandas raisingTypeError: Cannot convert pyarrow.lib.ChunkedArray to pyarrow.lib.Array. See SPARK-46776.Does this PR introduce any user-facing change?
Yes.
createDataFrame(pandas_df)no longer raises when a column is backed by a multi-chunk pyarrow array.How was this patch tested?
New test
ArrowTestsMixin.test_createDataFrame_pandas_chunked_array_backed, exercised on both classic and Spark Connect paths via the parity suite.Was this patch authored or co-authored using generative AI tooling?
No