Skip to content

Commit 2acc3ba

Browse files
committed
Revert "right column should not be skipped for nil comparisons in anti-joins"
This reverts commit 165e9b5.
1 parent 165e9b5 commit 2acc3ba

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

sql/rowexec/join_iters.go

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -256,6 +256,7 @@ const (
256256
esIncRight
257257
esRightIterEOF
258258
esCompare
259+
esRejectNull
259260
esRet
260261
)
261262

@@ -272,6 +273,7 @@ func (i *existsIter) Next(ctx *sql.Context) (sql.Row, error) {
272273
// when the secondaryProvider is empty
273274
// - antiJoin succeeds to RET when LOAD_RIGHT EOF's
274275
// - semiJoin fails when LOAD_RIGHT EOF's, falling back to LOAD_LEFT
276+
// - antiJoin fails when COMPARE returns true, falling back to LOAD_LEFT
275277
nextState := esIncLeft
276278
for {
277279
switch nextState {
@@ -323,6 +325,11 @@ func (i *existsIter) Next(ctx *sql.Context) (sql.Row, error) {
323325
return nil, err
324326
}
325327

328+
if res == nil && i.typ.IsExcludeNulls() {
329+
nextState = esRejectNull
330+
continue
331+
}
332+
326333
if !sql.IsTrue(res) {
327334
nextState = esIncRight
328335
} else {
@@ -337,6 +344,12 @@ func (i *existsIter) Next(ctx *sql.Context) (sql.Row, error) {
337344
nextState = esRet
338345
}
339346
}
347+
case esRejectNull:
348+
if i.typ.IsAnti() {
349+
nextState = esIncLeft
350+
} else {
351+
nextState = esIncRight
352+
}
340353
case esRet:
341354
return i.removeParentRow(left), nil
342355
default:

0 commit comments

Comments
 (0)