Skip to content

Commit

Permalink
exec: fix a bug with ON expression support for joiners
Browse files Browse the repository at this point in the history
Previously, a selection vector was ignored when applying a filter
on the batch. Now this is fixed. It is extremely difficult to write
a unit test for this at the moment because the filter planning code
lives in sql/distsqlrun.

Release note: None
  • Loading branch information
yuzefovich committed Sep 10, 2019
1 parent 0f9c8da commit 38853eb
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 0 deletions.
1 change: 1 addition & 0 deletions pkg/sql/exec/hashjoiner_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ func TestHashJoinerInt64(t *testing.T) {
}
}

// TODO(yuzefovich): add unit tests for cases with ON expression.
tcs := []struct {
leftTypes []coltypes.T
rightTypes []coltypes.T
Expand Down
4 changes: 4 additions & 0 deletions pkg/sql/exec/joiner_util_tmpl.go
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,10 @@ func (f *joinerFilter) setInputBatch(lBatch, rBatch coldata.Batch, lIdx, rIdx in
execerror.VectorizedInternalPanic("only one of lBatch and rBatch can be nil")
}
setOneSide := func(colOffset int, batch coldata.Batch, sourceTypes []coltypes.T, idx int) {
sel := batch.Selection()
if sel != nil {
idx = int(sel[idx])
}
for colIdx := 0; colIdx < batch.Width(); colIdx++ {
colType := sourceTypes[colIdx]
col := batch.ColVec(colIdx)
Expand Down
2 changes: 2 additions & 0 deletions pkg/sql/exec/mergejoiner_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ type mjTestInitializer interface {
initWithBatchSize(outBatchSize uint16)
}

// TODO(yuzefovich): add unit tests for cases with ON expression.

type mjTestCase struct {
description string
joinType sqlbase.JoinType
Expand Down

0 comments on commit 38853eb

Please sign in to comment.