maryannxue commented on a change in pull request #26625:
[SPARK-29893][SQL][followup] code cleanup for local shuffle reader
URL: https://github.com/apache/spark/pull/26625#discussion_r349161627
##########
File path:
sql/core/src/main/scala/org/apache/spark/sql/execution/adaptive/OptimizeLocalShuffleReader.scala
##########
@@ -39,41 +39,24 @@ import org.apache.spark.sql.internal.SQLConf
case class OptimizeLocalShuffleReader(conf: SQLConf) extends Rule[SparkPlan] {
import OptimizeLocalShuffleReader._
- def withProbeSideLocalReader(plan: SparkPlan): SparkPlan = {
- plan.transformDown {
+ // The build side is a broadcast query stage which should have been
optimized using local reader
+ // already. So we only need to deal with probe side here.
+ private def createProbeSideLocalReader(plan: SparkPlan): SparkPlan = {
+ val optimizedPlan = plan.transformDown {
case join @ BroadcastJoinWithShuffleLeft(shuffleStage, BuildRight) =>
val localReader = createLocalReader(shuffleStage)
join.asInstanceOf[BroadcastHashJoinExec].copy(left = localReader)
case join @ BroadcastJoinWithShuffleRight(shuffleStage, BuildLeft) =>
val localReader = createLocalReader(shuffleStage)
join.asInstanceOf[BroadcastHashJoinExec].copy(right = localReader)
}
- }
-
- def createLocalReader(plan: SparkPlan): LocalShuffleReaderExec = {
- plan match {
- case c: CoalescedShuffleReaderExec =>
- LocalShuffleReaderExec(c.child, Some(c.partitionStartIndices.length))
- case q: QueryStageExec => LocalShuffleReaderExec(q)
- }
- }
-
- override def apply(plan: SparkPlan): SparkPlan = {
- if (!conf.getConf(SQLConf.OPTIMIZE_LOCAL_SHUFFLE_READER_ENABLED)) {
- return plan
- }
-
- val optimizedPlan = plan match {
- case s: SparkPlan if canUseLocalShuffleReader(s) =>
- createLocalReader(s)
- case s: SparkPlan => withProbeSideLocalReader(s)
- }
def numExchanges(plan: SparkPlan): Int = {
Review comment:
nit: maybe we don't need to declare this a method any more. it's used only
once anyway.
----------------------------------------------------------------
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]