cloud-fan commented on a change in pull request #32699:
URL: https://github.com/apache/spark/pull/32699#discussion_r642258116



##########
File path: 
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/codegen/CodeGenerator.scala
##########
@@ -1039,21 +1039,25 @@ class CodegenContext extends Logging {
   def subexpressionEliminationForWholeStageCodegen(expressions: 
Seq[Expression]): SubExprCodes = {
     // Create a clear EquivalentExpressions and SubExprEliminationState mapping
     val equivalentExpressions: EquivalentExpressions = new 
EquivalentExpressions
-    val localSubExprEliminationExprs = mutable.HashMap.empty[Expression, 
SubExprEliminationState]
+    val localSubExprEliminationExprsForNonSplit =
+      mutable.HashMap.empty[Expression, SubExprEliminationState]
 
     // Add each expression tree and compute the common subexpressions.
     expressions.foreach(equivalentExpressions.addExprTree(_))
 
     // Get all the expressions that appear at least twice and set up the state 
for subexpression
     // elimination.
     val commonExprs = equivalentExpressions.getAllEquivalentExprs(1)
-    lazy val commonExprVals = commonExprs.map(_.head.genCode(this))
 
-    lazy val nonSplitExprCode = {
-      commonExprs.zip(commonExprVals).map { case (exprs, eval) =>
-        // Generate the code for this expression tree.
-        val state = SubExprEliminationState(eval.isNull, eval.value)
-        exprs.foreach(localSubExprEliminationExprs.put(_, state))
+    val nonSplitExprCode = {
+      commonExprs.map { exprs =>
+        val eval = 
withSubExprEliminationExprs(localSubExprEliminationExprsForNonSplit.toMap) {

Review comment:
       what does this recursive call of `withSubExprEliminationExprs` give us?




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