Skip to content

GH-46355: [Python] Fix table.to_struct_array with an empty table #46357

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 9, 2025

Conversation

hombit
Copy link
Contributor

@hombit hombit commented May 7, 2025

Rationale for this change

Currently pyarrow.Table.to_struct_array fails if table is empty, this PR fixes that. See issue #46355 for the reproducible example.

What changes are included in this PR?

Check if table is empty and create an empty chunked array using table schema for the array type

Are these changes tested?

I added a test for that, it failed before I implemented the fix

Are there any user-facing changes?

No

@hombit hombit requested review from AlenkaF, raulcd and rok as code owners May 7, 2025 20:11
@hombit hombit changed the title [Python] Fix Table.to_struct_array for empty table GH-46355: [Python] Fix Table.to_struct_array for empty table May 7, 2025
Copy link

github-actions bot commented May 7, 2025

Thanks for opening a pull request!

If this is not a minor PR. Could you open an issue for this pull request on GitHub? https://github.com/apache/arrow/issues/new/choose

Opening GitHub issues ahead of time contributes to the Openness of the Apache Arrow project.

Then could you also rename the pull request title in the following format?

GH-${GITHUB_ISSUE_ID}: [${COMPONENT}] ${SUMMARY}

or

MINOR: [${COMPONENT}] ${SUMMARY}

See also:

@github-actions github-actions bot added the awaiting review Awaiting review label May 7, 2025
Copy link

github-actions bot commented May 7, 2025

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

@hombit hombit force-pushed the py-fix-empty-table-to-struct-array branch from 237816c to cd0e002 Compare May 7, 2025 20:17
@hombit hombit marked this pull request as draft May 7, 2025 20:42
@hombit hombit force-pushed the py-fix-empty-table-to-struct-array branch from cd0e002 to e696376 Compare May 7, 2025 21:39
@hombit hombit force-pushed the py-fix-empty-table-to-struct-array branch from e696376 to cac55f9 Compare May 8, 2025 13:41
@hombit hombit force-pushed the py-fix-empty-table-to-struct-array branch from cac55f9 to 03f330d Compare May 8, 2025 13:44
@hombit hombit marked this pull request as ready for review May 8, 2025 13:52
@hombit
Copy link
Contributor Author

hombit commented May 8, 2025

@AlenkaF @raulcd @rok it is ready now, could you please review it?

Copy link
Member

@raulcd raulcd left a comment

Choose a reason for hiding this comment

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

Thanks for the PR. The fix sounds reasonable to me but I would like for @AlenkaF and/or @rok to take a look!

@github-actions github-actions bot added awaiting merge Awaiting merge and removed awaiting review Awaiting review labels May 8, 2025
@AlenkaF
Copy link
Member

AlenkaF commented May 8, 2025

@github-actions crossbow submit -g python

Copy link

github-actions bot commented May 8, 2025

Revision: 03f330d

Submitted crossbow builds: ursacomputing/crossbow @ actions-39637f523f

Task Status
example-python-minimal-build-fedora-conda GitHub Actions
example-python-minimal-build-ubuntu-venv GitHub Actions
test-conda-python-3.10 GitHub Actions
test-conda-python-3.10-hdfs-2.9.2 GitHub Actions
test-conda-python-3.10-hdfs-3.2.1 GitHub Actions
test-conda-python-3.10-pandas-latest-numpy-latest GitHub Actions
test-conda-python-3.11 GitHub Actions
test-conda-python-3.11-dask-latest GitHub Actions
test-conda-python-3.11-dask-upstream_devel GitHub Actions
test-conda-python-3.11-hypothesis GitHub Actions
test-conda-python-3.11-pandas-latest-numpy-1.26 GitHub Actions
test-conda-python-3.11-pandas-latest-numpy-latest GitHub Actions
test-conda-python-3.11-pandas-nightly-numpy-nightly GitHub Actions
test-conda-python-3.11-pandas-upstream_devel-numpy-nightly GitHub Actions
test-conda-python-3.11-spark-master GitHub Actions
test-conda-python-3.12 GitHub Actions
test-conda-python-3.12-cpython-debug GitHub Actions
test-conda-python-3.13 GitHub Actions
test-conda-python-3.9 GitHub Actions
test-conda-python-3.9-pandas-1.1.3-numpy-1.19.5 GitHub Actions
test-conda-python-emscripten GitHub Actions
test-cuda-python-ubuntu-22.04-cuda-11.7.1 GitHub Actions
test-debian-12-python-3-amd64 GitHub Actions
test-debian-12-python-3-i386 GitHub Actions
test-fedora-39-python-3 GitHub Actions
test-ubuntu-22.04-python-3 GitHub Actions
test-ubuntu-22.04-python-313-freethreading GitHub Actions
test-ubuntu-24.04-python-3 GitHub Actions

Copy link
Member

@AlenkaF AlenkaF left a comment

Choose a reason for hiding this comment

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

Looks good to me too, thanks! 👍
I have run Python extended builds, just in case. Lets wait for them to finish before merging.

@raulcd
Copy link
Member

raulcd commented May 9, 2025

The CI failures are unrelated.
The minimal examples fail because the fork repository does not have the development tags. This is a known issue:

The Python 3.10 are related to the test_gdb.py issue:

@raulcd raulcd changed the title GH-46355: [Python] Fix Table.to_struct_array for empty table GH-46355: [Python] Fix table.to_struct_array with an empty table May 9, 2025
@raulcd raulcd merged commit 88815a1 into apache:main May 9, 2025
17 of 18 checks passed
@raulcd raulcd removed the awaiting merge Awaiting merge label May 9, 2025
Copy link

After merging your PR, Conbench analyzed the 4 benchmarking runs that have been run so far on merge-commit 88815a1.

There were no benchmark performance regressions. 🎉

The full Conbench report has more details.

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.

3 participants