fix: no panic on empty partition in register_record_batches#1627
Open
fangchenli wants to merge 1 commit into
Open
fix: no panic on empty partition in register_record_batches#1627fangchenli wants to merge 1 commit into
fangchenli wants to merge 1 commit into
Conversation
`register_record_batches` read the schema via unchecked `partitions.0[0][0]`, which panics when a partition contains no record batches (e.g. the batches of an empty pyarrow table, whose `to_batches()` returns `[]`). Take the schema from the first available batch across all partitions and return a clear error when there is none, mirroring the empty-table handling added for `from_arrow_table` in apache#613. A non-empty later partition now also works instead of panicking on an empty leading one. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
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.
Which issue does this PR close?
Closes #1626 .
Rationale for this change
register_record_batchesread the schema via uncheckedpartitions.0[0][0], which panics when a partition contains no record batches (e.g. the batches of an empty pyarrow table, whoseto_batches()returns[]).What changes are included in this PR?
Take the schema from the first available batch across all partitions and return a clear error when there is none, mirroring the empty-table handling added for
from_arrow_tablein #613. A non-empty later partition now also works instead of panicking on an empty leading one.Are there any user-facing changes?
register_record_batches now raises a catchable Python Exception on empty input instead of aborting with a Rust panic