Github user yucai commented on a diff in the pull request: https://github.com/apache/spark/pull/21156#discussion_r200945621 --- Diff: sql/core/src/main/scala/org/apache/spark/sql/execution/joins/SortMergeJoinExec.scala --- @@ -76,8 +76,36 @@ case class SortMergeJoinExec( s"${getClass.getSimpleName} should not take $x as the JoinType") } - override def requiredChildDistribution: Seq[Distribution] = - HashClusteredDistribution(leftKeys) :: HashClusteredDistribution(rightKeys) :: Nil + private def avoidShuffleIfPossible( + joinKeys: Seq[Expression], + expressions: Seq[Expression]): Seq[Distribution] = { + val indices = expressions.map(x => joinKeys.indexWhere(_.semanticEquals(x))) --- End diff -- ``` case HashPartitioning(leftExpressions, _) if leftPartitioning.satisfies(ClusteredDistribution(leftKeys)) => avoidShuffleIfPossible(leftKeys, leftExpressions) ``` ` if leftPartitioning.satisfies(ClusteredDistribution(leftKeys))` has ensured `expressions` is a subset of `joinKeys`, so it would not return -1, right?
--- --------------------------------------------------------------------- To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org For additional commands, e-mail: reviews-h...@spark.apache.org