fix: return error instead of panic on schema mismatch in BatchCoalescer::push_batch#9390
Merged
alamb merged 1 commit intoapache:mainfrom Feb 11, 2026
Merged
Conversation
…er::push_batch Replace assert_eq! with an error return when the batch column count does not match the coalescer schema. The function already returns Result<(), ArrowError>, so callers can handle this gracefully.
e65cece to
467ad58
Compare
Jefffrey
approved these changes
Feb 11, 2026
Contributor
Jefffrey
left a comment
There was a problem hiding this comment.
Seems like a good idea to remove these panics in favour of errors 👍
One query I have is that push_batch() seems to have some fast paths/early returns before this check, so is it possible that existing behaviour sometimes was to ignore this potential column miscount 🤔
Contributor
It's possible, but not intended -- push_batch should be pushing the same columns each time |
alamb
approved these changes
Feb 11, 2026
Contributor
alamb
left a comment
There was a problem hiding this comment.
Thank ou @bvolpato-dd and @Jefffrey -- looks good to me too
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?
Rationale for this change
BatchCoalescer::push_batchcurrently uses a hardassert_eq!to check that the incoming batch has the same number of columns as the coalescer's schema. If there's a mismatch, the whole process panics.The function already returns
Result<(), ArrowError>, so there's no reason this can't be an error return instead. This is also how the rest of the arrow API handles the same situation —RecordBatch::try_newreturnsErr(ArrowError::InvalidArgumentError)for column count mismatches, and other checks in the same struct usedebug_assert!.We ran into this in production where a connector returned batches with a different schema than the plan expected. Instead of a query-level error, the whole process went down.
What changes are included in this PR?
assert_eq!(arrays.len(), self.in_progress_arrays.len())with anifcheck that returnsErr(ArrowError::InvalidArgumentError(...)).Are these changes tested?
Yes — three new tests:
test_push_batch_schema_mismatch_fewer_columns— coalescer expects 0 columns, batch has 1test_push_batch_schema_mismatch_more_columns— coalescer expects 2 columns, batch has 1test_push_batch_schema_mismatch_two_vs_zero— coalescer expects 0 columns, batch has 2 (matches the exact error we saw in production)Are there any user-facing changes?
BatchCoalescer::push_batchnow returnsErr(ArrowError::InvalidArgumentError)on column count mismatch instead of panicking. Any caller that was relying on the panic (unlikely) would need to handle the error instead.