viirya commented on a change in pull request #29975:
URL: https://github.com/apache/spark/pull/29975#discussion_r502996222
##########
File path:
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/codegen/CodeGenerator.scala
##########
@@ -1761,16 +1772,21 @@ object CodeGenerator extends Logging {
case ref: BoundReference if ctx.currentVars != null &&
ctx.currentVars(ref.ordinal) != null =>
- val ExprCode(_, isNull, value) = ctx.currentVars(ref.ordinal)
- collectLocalVariable(value)
- collectLocalVariable(isNull)
+ val exprCode = ctx.currentVars(ref.ordinal)
+ // If the referred variable is not evaluated yet.
+ if (exprCode.code != EmptyBlock) {
+ exprCodesNeedEvaluate += exprCode.copy()
Review comment:
Copying `exprCode` because we need the unevaluated `code` in `exprCode`,
but we also need to empty `code` of `exprCode`. We need copied code so we can
evaluate them before evaluating subexpressions. We need to empty `code` of
`exprCode` so we don't re-evaluate the code.
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]