Skip to content

Commit 00a4430

Browse files
committed
fix bug
1 parent 078d69b commit 00a4430

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

sql/core/src/main/scala/org/apache/spark/sql/execution/Exchange.scala

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -174,12 +174,14 @@ private[sql] case class AddExchange(sqlContext: SQLContext) extends Rule[SparkPl
174174
def addExchangeIfNecessary(
175175
partitioning: Partitioning,
176176
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)
180181
} else {
181182
child
182183
}
184+
}
183185

184186
if (meetsRequirements && compatible) {
185187
operator

0 commit comments

Comments
 (0)