Skip to content

[SPARK-55059][PYTHON] Remove empty table workaround in toPandas - #53824

Closed
Yicong-Huang wants to merge 1 commit into
apache:masterfrom
Yicong-Huang:SPARK-55059/refactor/remove-empty-table-workaround
Closed

[SPARK-55059][PYTHON] Remove empty table workaround in toPandas#53824
Yicong-Huang wants to merge 1 commit into
apache:masterfrom
Yicong-Huang:SPARK-55059/refactor/remove-empty-table-workaround

Conversation

@Yicong-Huang

@Yicong-HuangYicong-Huang commented Jan 15, 2026

Copy link
Copy Markdown
Contributor

What changes were proposed in this pull request?

Remove the SPARK-51112 workaround in _convert_arrow_table_to_pandas() that bypassed PyArrow's to_pandas() for empty tables.

Why are the changes needed?

The workaround was added because arrow-java's ListVector.getBufferSizeFor(0) returned 0, causing the offset buffer to be omitted for empty nested arrays in IPC serialization, which led to a segmentation fault in PyArrow.

This has been fixed upstream in arrow-java 19.0.0 (apache/arrow-java#343), which Spark adopted in SPARK-56000 (PR #54820). The workaround is no longer necessary.

Does this PR introduce any user-facing change?

No.

How was this patch tested?

Existing test test_to_pandas_for_empty_df_with_nested_array_columns passes.

Was this patch authored or co-authored using generative AI tooling?

No.

@Yicong-Huang
Yicong-Huang marked this pull request as draft January 15, 2026 23:30
@github-actions

Copy link
Copy Markdown

JIRA Issue Information

=== Improvement SPARK-55059 ===
Summary: Remove empty table workaround in toPandas
Assignee: None
Status: Open
Affected: ["4.2.0"]


This comment was automatically generated by GitHub Actions

@Yicong-Huang
Yicong-Huangforce-pushed the SPARK-55059/refactor/remove-empty-table-workaround branch from fa4f1a3 to 754c775CompareJanuary 16, 2026 00:53
@Yicong-Huang

Yicong-Huang commented Jan 16, 2026

Copy link
Copy Markdown
ContributorAuthor

waiting for #53822

@Yicong-Huang
Yicong-Huangforce-pushed the SPARK-55059/refactor/remove-empty-table-workaround branch from 754c775 to dc3371bCompareJanuary 16, 2026 01:04
@Yicong-Huang

Copy link
Copy Markdown
ContributorAuthor

depends on #54820

@Yicong-Huang
Yicong-Huangforce-pushed the SPARK-55059/refactor/remove-empty-table-workaround branch from 6421453 to af90c9cCompareMarch 18, 2026 20:25
@Yicong-HuangYicong-Huang changed the title [WIP][SPARK-55059][PYTHON] Remove empty table workaround in toPandas[SPARK-55059][PYTHON] Remove empty table workaround in toPandasMar 18, 2026
@Yicong-Huang
Yicong-Huang marked this pull request as ready for review March 18, 2026 20:26
@Yicong-Huang
Yicong-Huangforce-pushed the SPARK-55059/refactor/remove-empty-table-workaround branch from af90c9c to 2acd216CompareMarch 19, 2026 00:43
@Yicong-Huang

Copy link
Copy Markdown
ContributorAuthor

cc @ueshin@HyukjinKwon@zhengruifeng this is ready for review.

@HyukjinKwon

Copy link
Copy Markdown
Member

Merged to master.

terana pushed a commit to terana/spark that referenced this pull request Mar 23, 2026
### What changes were proposed in this pull request?
Remove the SPARK-51112 workaround in `_convert_arrow_table_to_pandas()` that bypassed PyArrow's `to_pandas()` for empty tables.
### Why are the changes needed?
The workaround was added because arrow-java's `ListVector.getBufferSizeFor(0)` returned 0, causing the offset buffer to be omitted for empty nested arrays in IPC serialization, which led to a segmentation fault in PyArrow.
This has been fixed upstream in arrow-java 19.0.0 ([apache/arrow-java#343](apache/arrow-java#343)), which Spark adopted in SPARK-56000 (PR apache#54820). The workaround is no longer necessary.
### Does this PR introduce _any_ user-facing change?
No.
### How was this patch tested?
Existing test `test_to_pandas_for_empty_df_with_nested_array_columns` passes.
### Was this patch authored or co-authored using generative AI tooling?
No.
Closesapache#53824 from Yicong-Huang/SPARK-55059/refactor/remove-empty-table-workaround.
Authored-by: Yicong Huang <17627829+Yicong-Huang@users.noreply.github.com>
Signed-off-by: Hyukjin Kwon <gurwls223@apache.org>
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

@Yicong-Huang@HyukjinKwon