manuzhang commented on a change in pull request #29692:
URL: https://github.com/apache/spark/pull/29692#discussion_r487633146
##########
File path:
sql/core/src/main/scala/org/apache/spark/sql/execution/adaptive/OptimizeSkewedJoin.scala
##########
@@ -248,6 +275,71 @@ case class OptimizeSkewedJoin(conf: SQLConf) extends
Rule[SparkPlan] {
} else {
smj
}
+
+ case bnl @ BroadcastNestedLoopJoinExec(
+ ShuffleStage(left: ShuffleStageInfo), _, BuildRight, joinType, _, _) =>
+ resolveBroadcastNLJoinSkew(bnl, left, joinType, BuildRight)
+ case bnl @ BroadcastNestedLoopJoinExec(
+ _, ShuffleStage(right: ShuffleStageInfo), BuildLeft, joinType, _, _) =>
+ resolveBroadcastNLJoinSkew(bnl, right, joinType, BuildLeft)
+ }
+
+ def resolveBroadcastNLJoinSkew(
+ bnl: BroadcastNestedLoopJoinExec,
+ stream: ShuffleStageInfo,
+ joinType: JoinType,
+ buildSide: BuildSide): SparkPlan = {
+ val streamMedSize = medianSize(stream.mapStats)
+ val numPartitions = stream.partitionsWithSizes.length
+ logDebug(
+ s"""
+ |Optimizing skewed join.
+ |${if (buildSide == BuildLeft) "Left" else "Right"} stream side
partitions size info:
+ |${getSizeInfo(streamMedSize, stream.mapStats.bytesByPartitionId)}
+ """.stripMargin)
+ val streamActualSizes = stream.partitionsWithSizes.map(_._2)
+ val streamTargetSize = targetSize(streamActualSizes, streamMedSize)
+ val streamSidePartitions = mutable.ArrayBuffer.empty[ShufflePartitionSpec]
+ var numSkewedStream = 0
+ for (partitionIndex <- 0 until numPartitions) {
Review comment:
This part looks like that in `optimizeSkewJoin`. Can we make it into a
general method ?
----------------------------------------------------------------
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]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]