cloud-fan commented on a change in pull request #27226: [SPARK-30524] [SQL] 
Disable OptimizeSkewedJoin rule when introducing additional shuffle
URL: https://github.com/apache/spark/pull/27226#discussion_r367228710
 
 

 ##########
 File path: 
sql/core/src/main/scala/org/apache/spark/sql/execution/adaptive/OptimizeSkewedJoin.scala
 ##########
 @@ -171,16 +208,20 @@ case class OptimizeSkewedJoin(conf: SQLConf) extends 
Rule[SparkPlan] {
               left, partitionId, leftMapIdStartIndices(i), leftEndMapId)
             val rightSkewedReader = SkewedPartitionReaderExec(right, 
partitionId,
               rightMapIdStartIndices(j), rightEndMapId)
+            val skewedLeft = reOptimizeChild(leftSkewedReader, leftPlan)
+            val skewedRight = reOptimizeChild(rightSkewedReader, rightPlan)
             subJoins += SortMergeJoinExec(leftKeys, rightKeys, joinType, 
condition,
-              s1.copy(child = leftSkewedReader), s2.copy(child = 
rightSkewedReader))
+              skewedLeft, skewedRight)
           }
         }
       }
       logDebug(s"number of skewed partitions is ${skewedPartitions.size}")
       if (skewedPartitions.nonEmpty) {
+        val visitedStages = HashSet.empty[Int]
         val optimizedSmj = smj.transformDown {
-          case sort @ SortExec(_, _, shuffleStage: ShuffleQueryStageExec, _) =>
-            sort.copy(child = PartialShuffleReaderExec(shuffleStage, 
skewedPartitions.toSet))
+          case shuffleStage: ShuffleQueryStageExec if 
!visitedStages.contains(shuffleStage.id) =>
 
 Review comment:
   to be safe, we should do `case s: ShuffleQueryStageExec if s.id == left.id 
|| s.id == right.id`

----------------------------------------------------------------
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:
[email protected]


With regards,
Apache Git Services

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

Reply via email to