Skip to content

Commit b9ae9bc

Browse files
hn50927mming7
authored andcommitted
apache#62 [SPARK-29284][SQL] Adaptive query execution works correctly when first stage partitions size is 0
1 parent cc4e1e1 commit b9ae9bc

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

sql/core/src/main/scala/org/apache/spark/sql/execution/exchange/ExchangeCoordinator.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,7 @@ class ExchangeCoordinator(
237237
// number of post-shuffle partitions.
238238
val partitionStartIndices =
239239
if (mapOutputStatistics.length == 0) {
240-
Array.empty[Int]
240+
Array(0)
241241
} else {
242242
estimatePartitionStartIndices(mapOutputStatistics)
243243
}

sql/core/src/test/scala/org/apache/spark/sql/execution/ExchangeCoordinatorSuite.scala

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -527,4 +527,15 @@ class ExchangeCoordinatorSuite extends SparkFunSuite with BeforeAndAfterAll {
527527
}
528528
withSparkSession(test, 4, None)
529529
}
530+
531+
test("SPARK-29284 adaptive query execution works correctly " +
532+
"when first stage partitions size is 0") {
533+
val test = { spark: SparkSession =>
534+
spark.sql("SET spark.sql.adaptive.enabled=true")
535+
spark.sql("SET spark.sql.shuffle.partitions=1")
536+
val resultDf = spark.range(0).distinct().groupBy().count()
537+
checkAnswer(resultDf, Row(0) :: Nil)
538+
}
539+
withSparkSession(test, 4, None)
540+
}
530541
}

0 commit comments

Comments
 (0)