Github user henryr commented on a diff in the pull request:

    https://github.com/apache/spark/pull/20560#discussion_r181253369
  
    --- Diff: 
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/optimizer/Optimizer.scala
 ---
    @@ -733,6 +735,17 @@ object EliminateSorts extends Rule[LogicalPlan] {
       }
     }
     
    +/**
    + * Removes Sort operation if the child is already sorted
    + */
    +object RemoveRedundantSorts extends Rule[LogicalPlan] {
    +  def apply(plan: LogicalPlan): LogicalPlan = plan transform {
    +    case Sort(orders, true, child) if child.outputOrdering.nonEmpty
    +        && SortOrder.orderingSatisfies(child.outputOrdering, orders) =>
    +      child
    +  }
    --- End diff --
    
    Filed SPARK-23973 for this


---

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

Reply via email to