Skip to content

PyArrow: Keep the row count when a scan selects no columns - #4161

Merged
kevinjqliu merged 3 commits into
apache:mainfrom
vibhuthespeedst:fix-empty-projection-row-count
Dec 2, 2026
Merged

kevinjqliu merged 3 commits into
apache:mainfrom
vibhuthespeedst:fix-empty-projection-row-count

Conversation

@vibhuthespeedst

Copy link
Copy Markdown
Contributor

Closes #4137

Rationale for this change

table.scan(selected_fields=()).to_arrow() returned 0 rows instead of the row count with no columns. Two places lost the rows: _to_requested_schema builds the struct from zero fields, which has length 0, and ArrowScan.to_table uses pa.concat_tables, which drops the rows of tables without columns.

Are these changes tested?

Yes, two tests in tests/io/test_pyarrow.py, with and without a row filter. Both fail without the fix.

Are there any user-facing changes?

Scans that select no columns now return the right number of rows.

Generated-by: AI assistant

@github-actions

Copy link
Copy Markdown

This pull request has been marked as stale due to 30 days of inactivity. It will be closed in 1 week if no further activity occurs. If you think that's incorrect or this pull request requires a review, please simply write any comment. If closed, you can revive the PR at any time and @mention a reviewer or discuss it on the dev@iceberg.apache.org list. Thank you for your contributions.

@github-actions github-actions Bot added the stale label Nov 26, 2026
@vibhuthespeedst

Copy link
Copy Markdown
Contributor Author

Still relevant, both new tests still fail on current main (7864d4c) without this change. @kevinjqliu could you take a look when you have time?

@github-actions github-actions Bot removed the stale label Nov 29, 2026

@Fokko Fokko 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.

Nice one @vibhuthespeedst 🙌

@Fokko
Fokko added this pull request to the merge queue Nov 30, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Nov 30, 2026
@Fokko
Fokko added this pull request to the merge queue Nov 30, 2026
@vibhuthespeedst

Copy link
Copy Markdown
Contributor Author

Thanks for the review @Fokko!

@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Nov 30, 2026
@vibhuthespeedst

Copy link
Copy Markdown
Contributor Author

I renamed arrow_schema in to_table, which caused the merge queue to fail. I’ve merged the latest changes from main and fixed the issue. @Fokko Could you please add it to the merge queue again?

@kevinjqliu kevinjqliu 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.

LGTM! Thanks @vibhuthespeedst!

@kevinjqliu
kevinjqliu enabled auto-merge December 2, 2026 01:57
@kevinjqliu
kevinjqliu added this pull request to the merge queue Dec 2, 2026
Merged via the queue into apache:main with commit ad93f40 Dec 2, 2026
24 of 26 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Scan with an empty projection (selected_fields=()) returns 0 rows

3 participants