marin-ma commented on code in PR #4952:
URL: https://github.com/apache/incubator-gluten/pull/4952#discussion_r1530596160


##########
backends-velox/src/main/scala/io/glutenproject/backendsapi/velox/SparkPlanExecApiImpl.scala:
##########
@@ -659,4 +662,81 @@ class SparkPlanExecApiImpl extends SparkPlanExecApi {
   ): GenerateExecTransformerBase = {
     GenerateExecTransformer(generator, requiredChildOutput, outer, 
generatorOutput, child)
   }
+
+  override def genPreProjectForGenerate(generate: GenerateExec): SparkPlan = {
+    if (supportsGenerate(generate)) {
+      val newGeneratorChild = 
generate.generator.asInstanceOf[UnaryExpression].child match {
+        case attr: Attribute => attr
+        case expr @ (Literal(_, _) | CreateMap(_, _) | CreateArray(_, _)) =>
+          Alias(expr, generatePreAliasName)()
+        case other =>
+          throw new UnsupportedOperationException(
+            s"Fail to execute ${generate.generator.getClass.getSimpleName} " +
+              s"with child type ${other.getClass.getSimpleName}")
+      }
+      generate.copy(
+        generator =
+          
generate.generator.withNewChildren(Seq(newGeneratorChild)).asInstanceOf[Generator],
+        child = ProjectExec(generate.child.output :+ newGeneratorChild, 
generate.child)

Review Comment:
   Do you mean by using `elimainateProjectList(generate.child.output, 
newGeneratorChild)`? `newGeneratorChild` can be a duplicated Attribute in 
`generate.child.output`. It shouldn't be eliminated because the native backend 
identifies the last field of projection as generator's input.



-- 
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: commits-unsubscr...@gluten.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscr...@gluten.apache.org
For additional commands, e-mail: commits-h...@gluten.apache.org

Reply via email to