wangyum commented on code in PR #50004: URL: https://github.com/apache/spark/pull/50004#discussion_r1970850047
########## sql/core/src/main/scala/org/apache/spark/sql/execution/exchange/EnsureRequirements.scala: ########## @@ -150,10 +150,15 @@ case class EnsureRequirements( // A: (No_Exchange, 100) <---> B: (Exchange, 120) // it's better to pick A and change B to (Exchange, 100) instead of picking B and insert a // new shuffle for A. - val candidateSpecsWithoutShuffle = candidateSpecs.filter { case (k, _) => - !children(k).isInstanceOf[ShuffleExchangeLike] + val (candidateSpecsWithShuffle, candidateSpecsWithoutShuffle) = candidateSpecs.partition { + case (k, _) => children(k).isInstanceOf[ShuffleExchangeLike] } - val finalCandidateSpecs = if (candidateSpecsWithoutShuffle.nonEmpty) { + val maxShufflePartNumOpt = candidateSpecsWithShuffle.values.map(_.numPartitions).maxOption + val finalCandidateSpecs = if (candidateSpecsWithoutShuffle.nonEmpty && + maxShufflePartNumOpt.forall { n => + n / candidateSpecsWithoutShuffle.values.map(_.numPartitions).max <= + conf.coalesceBucketsInJoinMaxBucketRatio Review Comment: https://github.com/apache/spark/blob/498519ee6bb4b0295d1df005175e4cbcbcb051e3/sql/core/src/main/scala/org/apache/spark/sql/execution/bucketing/CoalesceBucketsInJoin.scala#L89-L90 ########## sql/core/src/main/scala/org/apache/spark/sql/execution/exchange/EnsureRequirements.scala: ########## @@ -150,10 +150,15 @@ case class EnsureRequirements( // A: (No_Exchange, 100) <---> B: (Exchange, 120) // it's better to pick A and change B to (Exchange, 100) instead of picking B and insert a // new shuffle for A. Review Comment: 👌 -- 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-unsubscr...@spark.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org For additional commands, e-mail: reviews-h...@spark.apache.org