@@ -37,20 +37,19 @@ trait JoinCodegenSupport extends CodegenSupport with BaseJoinExec {
3737 */
3838 protected def getJoinCondition (
3939 ctx : CodegenContext ,
40- input : Seq [ExprCode ],
41- streamedPlan : SparkPlan ,
40+ streamVars : Seq [ExprCode ],
41+ streamPlan : SparkPlan ,
4242 buildPlan : SparkPlan ): (String , String , Seq [ExprCode ]) = {
4343 val buildRow = ctx.freshName(" buildRow" )
4444 val buildVars = genBuildSideVars(ctx, buildRow, buildPlan)
4545 val checkCondition = if (condition.isDefined) {
4646 val expr = condition.get
47- val outputs = streamedPlan.output ++ buildPlan.output
48- val vars = input ++ buildVars
49- // evaluate the variables used by condition
50- val eval = evaluateRequiredVariables(outputs, vars, expr.references)
47+ // evaluate the variables from build side that used by condition
48+ val eval = evaluateRequiredVariables(buildPlan.output, buildVars, expr.references)
5149 // filter the output via condition
52- ctx.currentVars = vars
53- val ev = BindReferences .bindReference(expr, outputs).genCode(ctx)
50+ ctx.currentVars = streamVars ++ buildVars
51+ val ev =
52+ BindReferences .bindReference(expr, streamPlan.output ++ buildPlan.output).genCode(ctx)
5453 val skipRow = s " ${ev.isNull} || ! ${ev.value}"
5554 s """
5655 | $eval
0 commit comments