Github user chenghao-intel commented on a diff in the pull request:

    https://github.com/apache/spark/pull/7334#discussion_r34434828
  
    --- Diff: 
sql/core/src/main/scala/org/apache/spark/sql/execution/SparkStrategies.scala ---
    @@ -332,8 +332,12 @@ private[sql] abstract class SparkStrategies extends 
QueryPlanner[SparkPlan] {
             execution.Sample(lb, ub, withReplacement, seed, planLater(child)) 
:: Nil
           case logical.LocalRelation(output, data) =>
             LocalTableScan(output, data) :: Nil
    -      case logical.Limit(IntegerLiteral(limit), child) =>
    -        execution.Limit(limit, planLater(child)) :: Nil
    +      case logical.Limit(IntegerLiteral(limit), child) => {
    +        val perPartitionLimit = execution.PartitionLocalLimit(limit, 
planLater(child))
    +        val globalLimit = execution.PartitionLocalLimit(
    +          limit, execution.Exchange(SinglePartition, Nil, 
perPartitionLimit))
    --- End diff --
    
    Instead of manually specify  a single `SinglePartition` in 
`SparkStrategies`, a better idea probably specifying the `requiredDistribution` 
in the physical operator `execution.PartitionLocalLimit`, as we did in 
`execution.Aggregate`, the rational we do that is, in the case of the 
`perPartitionLimit` is a `SinglePartition` already, we don't need to do anther 
shuffle, the `EnsureRequirements` can handle such kind of optimization for us.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to