wangshisan commented on a change in pull request #29266: URL: https://github.com/apache/spark/pull/29266#discussion_r465428028
########## File path: sql/core/src/main/scala/org/apache/spark/sql/execution/adaptive/OptimizeSkewedJoin.scala ########## @@ -250,6 +251,85 @@ case class OptimizeSkewedJoin(conf: SQLConf) extends Rule[SparkPlan] { } } + def optimizeSingleStageSkewJoin(plan: SparkPlan): SparkPlan = plan.transformUp { + case smj @ SortMergeJoinExec(_, _, joinType, _, + sort @ SortExec(_, _, ShuffleStage(qs: ShuffleStageInfo), _), right, _) => + if (qs.shuffleStage.shuffle.canChangeNumPartitions && canSplitLeftSide(joinType)) { + val (numSkewed, splitPartitions, partitionIndexes) = handleSkewed(qs) + if (numSkewed > 0) { + logInfo(s"number of skewed partitions $numSkewed") + smj.copy( + left = sort.copy(child = CustomShuffleReaderExec(qs.shuffleStage, splitPartitions)), + right = PartitionRecombinationExec(_ => partitionIndexes, + partitionIndexes.length, right), + isSkewJoin = true) + } else smj + } else { + smj + } + + case smj @ SortMergeJoinExec(_, _, _, _, left, + sort @ SortExec(_, _, ShuffleStage(qs: ShuffleStageInfo), _), _) => + val (numSkewed, splitPartitions, partitionIndexes) = handleSkewed(qs) Review comment: My fault, missed some code.. ---------------------------------------------------------------- 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. 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