zhengruifeng commented on a change in pull request #31468:
URL: https://github.com/apache/spark/pull/31468#discussion_r573433676
##########
File path: sql/core/src/main/scala/org/apache/spark/sql/execution/limit.scala
##########
@@ -52,16 +52,21 @@ case class CollectLimitExec(limit: Int, child: SparkPlan)
extends LimitExec {
SQLShuffleReadMetricsReporter.createShuffleReadMetrics(sparkContext)
override lazy val metrics = readMetrics ++ writeMetrics
protected override def doExecute(): RDD[InternalRow] = {
- val locallyLimited = child.execute().mapPartitionsInternal(_.take(limit))
- val shuffled = new ShuffledRowRDD(
- ShuffleExchangeExec.prepareShuffleDependency(
- locallyLimited,
- child.output,
- SinglePartition,
- serializer,
- writeMetrics),
- readMetrics)
- shuffled.mapPartitionsInternal(_.take(limit))
+ val childRDD = child.execute()
+ val singlePartitionRDD = if (childRDD.getNumPartitions != 1) {
Review comment:
refer to
[CoalesceExec.doExecute](https://github.com/apache/spark/blob/master/sql/core/src/main/scala/org/apache/spark/sql/execution/basicPhysicalOperators.scala#L715),
I update the fix to directly return empty RDD with single partition if
`childRDD.getNumPartitions == 0`
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]