File tree Expand file tree Collapse file tree 1 file changed +5
-3
lines changed
sql/core/src/main/scala/org/apache/spark/sql/execution Expand file tree Collapse file tree 1 file changed +5
-3
lines changed Original file line number Diff line number Diff line change @@ -174,12 +174,14 @@ private[sql] case class AddExchange(sqlContext: SQLContext) extends Rule[SparkPl
174
174
def addExchangeIfNecessary (
175
175
partitioning : Partitioning ,
176
176
child : SparkPlan ,
177
- rowOrdering : Option [Ordering [Row ]] = None ): SparkPlan =
178
- if (child.outputPartitioning != partitioning) {
179
- Exchange (partitioning, child, sort = child.outputOrdering != rowOrdering)
177
+ rowOrdering : Option [Ordering [Row ]] = None ): SparkPlan = {
178
+ val needSort = child.outputOrdering != rowOrdering
179
+ if (child.outputPartitioning != partitioning || needSort) {
180
+ Exchange (partitioning, child, sort = needSort)
180
181
} else {
181
182
child
182
183
}
184
+ }
183
185
184
186
if (meetsRequirements && compatible) {
185
187
operator
You can’t perform that action at this time.
0 commit comments