bug: no column projection should still persist row count#4444
Conversation
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.
|
@mbutrovich , thank you for the review. I made changes per review comments . Please take a look whenever you get a chance |
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.