File tree Expand file tree Collapse file tree 1 file changed +14
-12
lines changed
sql/core/src/main/scala/org/apache/spark/sql/execution Expand file tree Collapse file tree 1 file changed +14
-12
lines changed Original file line number Diff line number Diff line change @@ -271,23 +271,25 @@ private[sql] case class EnsureRequirements(sqlContext: SQLContext) extends Rule[
271271 partitioning : Partitioning ,
272272 rowOrdering : Seq [SortOrder ],
273273 child : SparkPlan ): SparkPlan = {
274- val needSort = rowOrdering.nonEmpty && child.outputOrdering != rowOrdering
275- val needsShuffle = child.outputPartitioning != partitioning
276274
277- val withShuffle = if (needsShuffle) {
278- Exchange (partitioning, child)
279- } else {
280- child
275+ def addShuffleIfNecessary (child : SparkPlan ): SparkPlan = {
276+ if (child.outputPartitioning != partitioning) {
277+ Exchange (partitioning, child)
278+ } else {
279+ child
280+ }
281281 }
282282
283- val withSort = if (needSort) {
284- sqlContext.planner.BasicOperators .getSortOperator(
285- rowOrdering, global = false , withShuffle)
286- } else {
287- withShuffle
283+ def addSortIfNecessary (child : SparkPlan ): SparkPlan = {
284+ if (rowOrdering.nonEmpty && child.outputOrdering != rowOrdering) {
285+ sqlContext.planner.BasicOperators .getSortOperator(
286+ rowOrdering, global = false , child)
287+ } else {
288+ child
289+ }
288290 }
289291
290- withSort
292+ addSortIfNecessary(addShuffleIfNecessary(child))
291293 }
292294
293295 if (meetsRequirements && compatible && ! needsAnySort) {
You can’t perform that action at this time.
0 commit comments