File tree Expand file tree Collapse file tree 1 file changed +7
-2
lines changed
sql/core/src/main/scala/org/apache/spark/sql/execution Expand file tree Collapse file tree 1 file changed +7
-2
lines changed Original file line number Diff line number Diff line change @@ -253,9 +253,14 @@ private[sql] case class EnsureRequirements(sqlContext: SQLContext) extends Rule[
253253
254254 private def ensureDistributionAndOrdering (operator : SparkPlan ): SparkPlan = {
255255
256- // Precondition: joins' children have compatible partitionings.
257-
258256 def addShuffleIfNecessary (child : SparkPlan , requiredDistribution : Distribution ): SparkPlan = {
257+ // A pre-condition of ensureDistributionAndOrdering is that joins' children have compatible
258+ // partitionings. Thus, we only need to check whether the output partitionings satisfy
259+ // the required distribution. In the case where the children are all compatible, then they
260+ // will either all satisfy the required distribution or will all fail to satisfy it:, since
261+ // (A.guarantees(B) && B.satisfies(C)) => A.satisfies(C).
262+ // Therefore, if all children are compatible then either all or none of them will shuffled to
263+ // ensure that the distribution requirements are met.
259264 if (child.outputPartitioning.satisfies(requiredDistribution)) {
260265 child
261266 } else {
You can’t perform that action at this time.
0 commit comments