You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@spark.apache.org by GitBox <gi...@apache.org> on 2020/02/11 11:09:33 UTC

[GitHub] [spark] cloud-fan commented on a change in pull request #27530: [SPARK-30780][SQL] Empty LocalTableScan should use RDD without partitions

cloud-fan commented on a change in pull request #27530: [SPARK-30780][SQL] Empty LocalTableScan should use RDD without partitions
URL: https://github.com/apache/spark/pull/27530#discussion_r377569895
 
 

 ##########
 File path: sql/core/src/main/scala/org/apache/spark/sql/execution/LocalTableScanExec.scala
 ##########
 @@ -45,10 +45,14 @@ case class LocalTableScanExec(
     }
   }
 
-  private lazy val numParallelism: Int = math.min(math.max(unsafeRows.length, 1),
-    sqlContext.sparkContext.defaultParallelism)
-
-  private lazy val rdd = sqlContext.sparkContext.parallelize(unsafeRows, numParallelism)
+  @transient private lazy val rdd: RDD[InternalRow] = {
+    if (rows.isEmpty) {
+      sqlContext.sparkContext.emptyRDD
+    } else {
+      val numSlices = math.min(unsafeRows.length, sqlContext.sparkContext.defaultParallelism)
+      sqlContext.sparkContext.parallelize(unsafeRows, numSlices)
 
 Review comment:
   `parallelize` need to respect the `numSlices` parameter, even if the data is empty.

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


With regards,
Apache Git Services

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