viirya commented on code in PR #37195:
URL: https://github.com/apache/spark/pull/37195#discussion_r923046512


##########
sql/core/src/main/scala/org/apache/spark/sql/execution/datasources/v2/V2ScanRelationPushDown.scala:
##########
@@ -378,8 +406,12 @@ object V2ScanRelationPushDown extends Rule[LogicalPlan] 
with PredicateHelper wit
       }
       (operation, isPushed && !isPartiallyPushed)
     case s @ Sort(order, _, operation @ ScanOperation(project, filter, 
sHolder: ScanBuilderHolder))
-        if filter.isEmpty && CollapseProject.canCollapseExpressions(
-          order, project, alwaysInline = true) =>
+        // Without building the Scan, we do not know the resulting column 
names after aggregate
+        // push-down, and thus can't push down Top-N which needs to know the 
ordering column names.
+        // TODO: we can support simple cases like GROUP BY columns directly 
and ORDER BY the same
+        //       columns, which we know the resulting column names: the 
original table columns.
+        if sHolder.pushedAggregate.isEmpty && filter.isEmpty &&
+          CollapseProject.canCollapseExpressions(order, project, alwaysInline 
= true) =>

Review Comment:
   Hmm, is this regression? I.e. previously we can pushdown, but now we cannot?



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