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



##########
File path: 
sql/core/src/main/scala/org/apache/spark/sql/execution/datasources/v2/V2ScanRelationPushDown.scala
##########
@@ -93,22 +92,28 @@ object V2ScanRelationPushDown extends Rule[LogicalPlan] 
with PredicateHelper {
     case aggNode @ Aggregate(groupingExpressions, resultExpressions, child) =>
       child match {
         case ScanOperation(project, filters, sHolder: ScanBuilderHolder)
-          if filters.isEmpty && 
project.forall(_.isInstanceOf[AttributeReference]) =>
+          if filters.isEmpty && project.forall(_.deterministic) =>
           sHolder.builder match {
             case r: SupportsPushDownAggregates =>
+              val aliasMap = getAliasMap(project)
+              val newResultExpressions = 
resultExpressions.map(replaceAliasWithAttr(_, aliasMap))
+              val newGroupingExpressions = groupingExpressions.map {
+                case e: NamedExpression => replaceAliasWithAttr(e, aliasMap)
+                case other => other
+              }

Review comment:
       can we make the code more explicit? We need to clearly show the steps
   1. collapse aggregate and project
   2. remove the alias from aggregate functions and group by expressions (this 
logic should be put here instead of `AliasHelper` as this is not a common logic)
   3. push down agg
   4. add back alias for group by expressions only.




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