bug: no column projection should still persist row count#4444
Open
coderfender wants to merge 3 commits into
Open
bug: no column projection should still persist row count#4444coderfender wants to merge 3 commits into
coderfender wants to merge 3 commits into
Conversation
mbutrovich
requested changes
May 27, 2026
Contributor
mbutrovich
left a comment
There was a problem hiding this comment.
Nice find, thanks @coderfender!
A couple of suggestions before merging.
CI: check-missing-suites. dev/ci/check-suites.py walks both pr_build_linux.yml and pr_build_macos.yml, so UtilsSuite also needs to be added to .github/workflows/pr_build_macos.yml.
Consider gating the setRowCount calls on the no-column case. The condition itself documents why the call exists, and the non-empty path stays byte-identical to today.
val root = new VectorSchemaRoot(fieldVectors.asJava)
if (fieldVectors.isEmpty) {
// VSR cannot infer rowCount without field vectors
root.setRowCount(batch.numRows())
}if (targetRoot.getSchema.getFields.isEmpty) {
// VSRAppender does not update rowCount with no columns
targetRoot.setRowCount(totalRows.toInt)
}Follow-up. A SQL-level test like SELECT count(*) FROM big CROSS JOIN small with a broadcast hint would have caught this pre-fix. Worth leaving a TODO pointing at the native BNLJ PR so it lands there.
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 : #4445 discovered while implementing native
BroadcastNestedLoopJoin.Rationale for this change
Utils.serializeBatchesandUtils.coalesceBroadcastBatcheslose the rowcount when the input batch has zero columns, so a column-pruned broadcast
relation arrives at the receiver as empty.
Both functions build an Arrow
VectorSchemaRootfrom the batch's fieldvectors. With zero columns the VSR has nothing to infer rowCount from and
defaults to 0; IPC then encodes
length = 0.Latent until now because every
prior caller of
CometBroadcastExchangeExecwas BHJ, whose build sidealways carries join keys. Native
BroadcastNestedLoopJoinimplementation exposed this bug when build side that can broadcast a 0-column side (e.g.SELECT count(*) FROM big, small), resulting in 0 rowsWhat changes are included in this PR?
Utils.serializeBatches:root.setRowCount(batch.numRows())after VSRconstruction.
Utils.coalesceBroadcastBatches:targetRoot.setRowCount(totalRows.toInt)How are these changes tested?
New
UtilsSuitetests for 0-column batches.