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

    https://github.com/apache/spark/pull/10896#discussion_r75603771
  
    --- Diff: 
sql/core/src/main/scala/org/apache/spark/sql/execution/exchange/EnsureRequirements.scala
 ---
    @@ -151,18 +152,39 @@ case class EnsureRequirements(conf: SQLConf) extends 
Rule[SparkPlan] {
       private def ensureDistributionAndOrdering(operator: SparkPlan): 
SparkPlan = {
         val requiredChildDistributions: Seq[Distribution] = 
operator.requiredChildDistribution
         val requiredChildOrderings: Seq[Seq[SortOrder]] = 
operator.requiredChildOrdering
    -    var children: Seq[SparkPlan] = operator.children
    -    assert(requiredChildDistributions.length == children.length)
    -    assert(requiredChildOrderings.length == children.length)
    +    assert(requiredChildDistributions.length == operator.children.length)
    +    assert(requiredChildOrderings.length == operator.children.length)
     
         // Ensure that the operator's children satisfy their output 
distribution requirements:
    -    children = children.zip(requiredChildDistributions).map {
    -      case (child, distribution) if 
child.outputPartitioning.satisfies(distribution) =>
    -        child
    -      case (child, BroadcastDistribution(mode)) =>
    -        BroadcastExchangeExec(mode, child)
    -      case (child, distribution) =>
    -        ShuffleExchange(createPartitioning(distribution, 
defaultNumPreShufflePartitions), child)
    +    val childrenWithDist = 
operator.children.zip(requiredChildDistributions)
    +
    +    def createShuffleExchange(dist: Distribution, child: SparkPlan) =
    +      ShuffleExchange(createPartitioning(dist, 
defaultNumPreShufflePartitions), child)
    +
    +    var (parent, children) = if (!AggUtils.isAggregate(operator)) {
    --- End diff --
    
    Can we try to simplify the if-else here? We only need to isolate aggregates 
for which can be partially aggregated and for which the distribution does not 
match.


---
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 infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

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

Reply via email to