func (b *planBuilder) buildApply(outerPlan, innerPlan LogicalPlan, checker *ApplyConditionChecker) LogicalPlan {
	ap := &Apply{
		Checker:         checker,
		baseLogicalPlan: newBaseLogicalPlan(App, b.allocator),
	}
	ap.self = ap
	ap.initIDAndContext(b.ctx)
	addChild(ap, outerPlan)
	addChild(ap, innerPlan)
	corColumns := innerPlan.extractCorrelatedCols()
	ap.correlated = outerPlan.IsCorrelated()
	for _, corCol := range corColumns {
		// If the outer column can't be resolved from this outer schema, it should be resolved by outer schema.
		if idx := outerPlan.GetSchema().GetIndex(&corCol.Column); idx == -1 {
			ap.correlated = true
			break
		}
	}
	innerSchema := innerPlan.GetSchema().Clone()
	if checker == nil {
		for _, col := range innerSchema {
			col.IsAggOrSubq = true
		}
		ap.SetSchema(append(outerPlan.GetSchema().Clone(), innerSchema...))
	} else {
		ap.SetSchema(append(outerPlan.GetSchema().Clone(), &expression.Column{
			FromID:      ap.id,
			ColName:     model.NewCIStr("exists_row"),
			RetType:     types.NewFieldType(mysql.TypeTiny),
			IsAggOrSubq: true,
		}))
	}
	return ap
}
// buildApply builds apply plan with outerPlan and innerPlan. Everytime we fetch a record from outerPlan and apply it to
// innerPlan. This way is the so-called correlated execution.
buildApply builds apply plan with outerPlan and innerPlan. Everytime we fetch a record from outerPlan and apply it to
innerPlan. This way is the so-called correlated execution.
// buildApply builds apply plan with outerPlan and innerPlan . Everytime we fetch a record from outerPlan and apply it to // innerPlan . This way is the so - called correlated execution .
func (b *planBuilder) buildApply(outerPlan, innerPlan LogicalPlan, checker *ApplyConditionChecker) LogicalPlan {
	ap := &Apply{
		Checker:         checker,
		baseLogicalPlan: newBaseLogicalPlan(App, b.allocator),
	}
	ap.self = ap
	ap.initIDAndContext(b.ctx)
	addChild(ap, outerPlan)
	addChild(ap, innerPlan)
	corColumns := innerPlan.extractCorrelatedCols()
	ap.correlated = outerPlan.IsCorrelated()
	for _, corCol := range corColumns {
		if idx := outerPlan.GetSchema().GetIndex(&corCol.Column); idx == -1 {
			ap.correlated = true
			break
		}
	}
	innerSchema := innerPlan.GetSchema().Clone()
	if checker == nil {
		for _, col := range innerSchema {
			col.IsAggOrSubq = true
		}
		ap.SetSchema(append(outerPlan.GetSchema().Clone(), innerSchema...))
	} else {
		ap.SetSchema(append(outerPlan.GetSchema().Clone(), &expression.Column{
			FromID:      ap.id,
			ColName:     model.NewCIStr("exists_row"),
			RetType:     types.NewFieldType(mysql.TypeTiny),
			IsAggOrSubq: true,
		}))
	}
	return ap
}
func ( b * planBuilder ) buildApply ( outerPlan , innerPlan LogicalPlan , checker * ApplyConditionChecker ) LogicalPlan { ap := & Apply { Checker : checker , baseLogicalPlan : newBaseLogicalPlan ( App , b . allocator ) , } ap . self = ap ap . initIDAndContext ( b . ctx ) addChild ( ap , outerPlan ) addChild ( ap , innerPlan ) corColumns := innerPlan . extractCorrelatedCols ( ) ap . correlated = outerPlan . IsCorrelated ( ) for _ , corCol := range corColumns { if idx := outerPlan . GetSchema ( ) . GetIndex ( & corCol . Column ) ; idx == - 1 { ap . correlated = true break } } innerSchema := innerPlan . GetSchema ( ) . Clone ( ) if checker == nil { for _ , col := range innerSchema { col . IsAggOrSubq = true } ap . SetSchema ( append ( outerPlan . GetSchema ( ) . Clone ( ) , innerSchema ... ) ) } else { ap . SetSchema ( append ( outerPlan . GetSchema ( ) . Clone ( ) , & expression . Column { FromID : ap . id , ColName : model . NewCIStr ( " " ) , RetType : types . NewFieldType ( mysql . TypeTiny ) , IsAggOrSubq : true , } ) ) } return ap }
buildApply builds apply plan with outerPlan and innerPlan.
buildApply builds apply plan with outerPlan and innerPlan .
// If the outer column can't be resolved from this outer schema, it should be resolved by outer schema.