You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@spark.apache.org by GitBox <gi...@apache.org> on 2022/03/10 15:57:10 UTC

[GitHub] [spark] cloud-fan commented on a change in pull request #35710: [SPARK-38391][SQL] Datasource v2 supports complete partial sort pushdown

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



##########
File path: sql/core/src/main/scala/org/apache/spark/sql/execution/datasources/v2/V2ScanRelationPushDown.scala
##########
@@ -362,7 +362,11 @@ object V2ScanRelationPushDown extends Rule[LogicalPlan] with PredicateHelper {
         if (topNPushed) {
           sHolder.pushedLimit = Some(limit)
           sHolder.sortOrders = orders
-          operation
+          sHolder.builder match {
+            case s: SupportsPushDownTopN if s.supportCompleteSortPushDown() =>
+              operation
+            case _ => s

Review comment:
       This makes the top N pushdown look like a hint: we notify the source that a top N is needed, but the Spark query plan is not changed.
   
   This is definitely not optimal: Spark still does a sort, and probably a shuffle if the limit is large. Performance-wise, I think it's the same as pushing down a limit. How about a simpler approach: if we can't push down top N, we just push down limit without changing the plan. Then we don't need to change DS v2 APIs.




-- 
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: reviews-unsubscribe@spark.apache.org

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



---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org