lgbo-ustc commented on code in PR #7779:
URL: https://github.com/apache/incubator-gluten/pull/7779#discussion_r1830475511


##########
backends-clickhouse/src/main/scala/org/apache/gluten/extension/PushdownAggregatePreProjectionAheadExpand.scala:
##########
@@ -93,11 +93,33 @@ case class 
PushdownAggregatePreProjectionAheadExpand(session: SparkSession)
           return hashAggregate
         }
 
+        def projectInputExists(expr: Expression, inputs: Seq[Attribute]): 
Boolean = {
+          expr.children.foreach {
+            case a: Attribute =>
+              var exist = false
+              for (input <- inputs if input.name.equals(a.name) && 
input.exprId.equals(a.exprId)) {
+                exist = true
+              }
+              return exist
+            case p: Expression =>
+              return projectInputExists(p, inputs)
+            case _ =>
+              return true
+          }
+          true
+        }
+
+        preProjectExprs.foreach(
+          p => {
+            if (!projectInputExists(p, rootChild.output)) {
+              return hashAggregate
+            }
+          })
+

Review Comment:
   ```scala
           val rootChild = expand.child
           val childInputAttrbutes = rootChild.output
           val couldPushDown = preProjectExprs.forall {
             projection =>
               projection.forall {
                 expr =>
                   expr match {
                     case attribute: Attribute => 
childInputAttrbutes.indexOf(attribute) != -1
                     case _ => true
                   }
               }
           }
   ```



-- 
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: [email protected]

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