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/08/17 09:44:00 UTC

[GitHub] [spark] cloud-fan commented on a diff in pull request #37519: [SPARK-40050][SQL] Eliminate the `Sort` if there is a `LocalLimit` between `Join` and `Sort`

cloud-fan commented on code in PR #37519:
URL: https://github.com/apache/spark/pull/37519#discussion_r947697059


##########
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/optimizer/Optimizer.scala:
##########
@@ -1528,8 +1528,8 @@ object EliminateSorts extends Rule[LogicalPlan] {
       applyLocally.lift(child).getOrElse(child)
     case s @ Sort(_, global, child) => s.copy(child = recursiveRemoveSort(child, global))
     case j @ Join(originLeft, originRight, _, cond, _) if cond.forall(_.deterministic) =>
-      j.copy(left = recursiveRemoveSort(originLeft, true),
-        right = recursiveRemoveSort(originRight, true))
+      j.copy(left = recursiveRemoveSort(originLeft, true, canEliminateThroughLocalLimit = true),
+        right = recursiveRemoveSort(originRight, true, canEliminateThroughLocalLimit = true))
     case g @ Aggregate(_, aggs, originChild) if isOrderIrrelevantAggs(aggs) =>
       g.copy(child = recursiveRemoveSort(originChild, true))

Review Comment:
   I think aggregate can eliminate sort through local limit as well. The point is, local limit does not guarantee any semantic (the result depends on the data partitioning) and end-users won't have any expectations for it.



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