maropu commented on a change in pull request #31468:
URL: https://github.com/apache/spark/pull/31468#discussion_r573435246



##########
File path: sql/core/src/main/scala/org/apache/spark/sql/execution/limit.scala
##########
@@ -200,28 +210,32 @@ case class TakeOrderedAndProjectExec(
   protected override def doExecute(): RDD[InternalRow] = {
     val ord = new LazilyGeneratedOrdering(sortOrder, child.output)
     val childRDD = child.execute()
-    val singlePartitionRDD = if (childRDD.getNumPartitions > 1) {
-      val localTopK = childRDD.mapPartitions { iter =>
-        org.apache.spark.util.collection.Utils.takeOrdered(iter.map(_.copy()), 
limit)(ord)
-      }
-      new ShuffledRowRDD(
-        ShuffleExchangeExec.prepareShuffleDependency(
-          localTopK,
-          child.output,
-          SinglePartition,
-          serializer,
-          writeMetrics),
-        readMetrics)
+    if (childRDD.getNumPartitions == 0) {
+      sparkContext.parallelize(Array.empty[InternalRow], 1)

Review comment:
       nit: how about using `ParallelCollectionRDD` directly?




----------------------------------------------------------------
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:
us...@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org
For additional commands, e-mail: reviews-h...@spark.apache.org

Reply via email to