viirya commented on a change in pull request #29975:
URL: https://github.com/apache/spark/pull/29975#discussion_r502537451



##########
File path: 
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/codegen/CodeGenerator.scala
##########
@@ -90,8 +90,13 @@ case class SubExprEliminationState(isNull: ExprValue, value: 
ExprValue)
  * @param codes Strings representing the codes that evaluate common 
subexpressions.
  * @param states Foreach expression that is participating in subexpression 
elimination,
  *               the state to use.
+ * @param exprCodesNeedEvaluate Some expression codes that need to be evaluate 
before
+ *                              calling common subexpressions.
  */
-case class SubExprCodes(codes: Seq[String], states: Map[Expression, 
SubExprEliminationState])
+case class SubExprCodes(
+  codes: Seq[String],
+  states: Map[Expression, SubExprEliminationState],
+  exprCodesNeedEvaluate: Seq[ExprCode])

Review comment:
       Yes, this is needed. `ProjectExec` doesn't require all its child's 
outputs to be evaluated in advance. Instead it only early evaluates the outputs 
used more than twice (deferring evaluation). So we need to extract these 
variables used by subexpressions and evaluate them before subexpressions.




----------------------------------------------------------------
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]

Reply via email to