Skip to content

Commit 70280ea

Browse files
committed
update
Signed-off-by: Weizhen Wang <wangweizhen@pingcap.com>
1 parent 446f2ef commit 70280ea

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

pkg/planner/core/operator/logicalop/logical_join.go

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -273,12 +273,11 @@ func (p *LogicalJoin) CanConvertAntiJoin(ret []expression.Expression, selectSch
273273
switch p.JoinType {
274274
case base.LeftOuterJoin:
275275
inner := p.children[0]
276-
var outerSch []*expression.Column
277-
fullJoinOutPutColumns := slices.Clone(p.Schema().Columns)
278276
innerSch := inner.Schema()
279-
outerSch = slices.DeleteFunc(fullJoinOutPutColumns, func(c *expression.Column) bool {
277+
outerSch := intset.NewFastIntSet()
278+
expression.ExtractColumnsSetFromExpressions(&outerSch, func(c *expression.Column) bool {
280279
return innerSch.Contains(c)
281-
})
280+
}, expression.Column2Exprs(p.Schema().Columns)...)
282281
var sf *expression.ScalarFunction
283282
var ok bool
284283
if sf, ok = ret[0].(*expression.ScalarFunction); !ok {
@@ -292,13 +291,14 @@ func (p *LogicalJoin) CanConvertAntiJoin(ret []expression.Expression, selectSch
292291
// It is a Not expression. then we check whether it has a IsNull expression.
293292
if isNullcol, ok := args[0].(*expression.Column); ok {
294293
// column in IsNull expression is from the outer side columns.
295-
selConditionColInOuter := slices.ContainsFunc(outerSch, func(c *expression.Column) bool {
296-
return c.UniqueID == isNullcol.UniqueID
297-
})
294+
selConditionColInOuter := outerSch.Has(int(isNullcol.UniqueID))
298295
// selection's schema doesn't contain the outer side columns.
299-
selOutColNotInOuter := !slices.ContainsFunc(outerSch, func(c *expression.Column) bool {
300-
return selectSch.Contains(c)
301-
})
296+
selOutColNotInOuter := true
297+
for _, c := range selectSch.Columns {
298+
if outerSch.Has(int(c.UniqueID)) {
299+
selOutColNotInOuter = false
300+
}
301+
}
302302
if selConditionColInOuter && selOutColNotInOuter {
303303
canConvert = true
304304
}

0 commit comments

Comments
 (0)