karuppayya commented on a change in pull request #28715:
URL: https://github.com/apache/spark/pull/28715#discussion_r438569824



##########
File path: 
sql/core/src/main/scala/org/apache/spark/sql/execution/GenerateExec.scala
##########
@@ -226,18 +226,33 @@ case class GenerateExec(
       "0"
     }
     val numOutput = metricTerm(ctx, "numOutputRows")
+    val requiredInput =
+      evaluateRequiredVariablesExpr(child.output,
+        input, parent.inputSet) ++ position ++ values
     s"""
        |${data.code}
        |$initMapData
        |int $numElements = ${data.isNull} ? 0 : ${data.value}.numElements();
        |for (int $index = $init; $index < $numElements; $index++) {
        |  $numOutput.add(1);
        |  $updateRowData
-       |  ${consume(ctx, input ++ position ++ values)}
+       |  ${consume(ctx, requiredInput)}
        |}
      """.stripMargin
   }
 
+  /**
+   * Returns [ExprCode] for required attributes
+   */
+  private def evaluateRequiredVariablesExpr(

Review comment:
       @cloud-fan Should this method be in introduced in 
WholeStageCodeGenExec.scala?




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