viirya commented on a change in pull request #33082: URL: https://github.com/apache/spark/pull/33082#discussion_r659183793
########## File path: sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/codegen/CodeGenerator.scala ########## @@ -1766,19 +1766,20 @@ object CodeGenerator extends Logging { argSet += JavaCode.variable(ctx.INPUT_ROW, classOf[InternalRow]) } + val stack = mutable.Stack[Expression](expr) + // Collects local variables from a given `expr` tree - val collectLocalVariable = (ev: ExprValue) => ev match { + val collectLocalVariable = (ev: ExprValue, e: Expression) => ev match { case vv: VariableValue => argSet += vv - case _ => + case _ => stack.pushAll(e.children) } - val stack = mutable.Stack[Expression](expr) while (stack.nonEmpty) { stack.pop() match { case e if subExprs.contains(e) => val SubExprEliminationState(isNull, value) = subExprs(e) - collectLocalVariable(value) - collectLocalVariable(isNull) + collectLocalVariable(value, e) + collectLocalVariable(isNull, e) Review comment: Oh, some `SubExprEliminationState` contains not `VariableValue` but still some statements that includes other expressions? -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org For additional commands, e-mail: reviews-h...@spark.apache.org