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/25 06:15:10 UTC

[GitHub] [spark] beliefer commented on a change in pull request #27429: [SPARK-28330][SQL] Support ANSI SQL: result offset clause in query expression

beliefer commented on a change in pull request #27429: [SPARK-28330][SQL] Support ANSI SQL: result offset clause in query expression
URL: https://github.com/apache/spark/pull/27429#discussion_r383677027
 
 

 ##########
 File path: sql/core/src/main/scala/org/apache/spark/sql/execution/limit.scala
 ##########
 @@ -161,6 +164,46 @@ case class GlobalLimitExec(limit: Int, child: SparkPlan) extends BaseLimitExec {
   override def outputOrdering: Seq[SortOrder] = child.outputOrdering
 }
 
+/**
+ * Skip the first `offset` elements then take the first `limit` of the following elements in
+ *  the child's single output partition.
+ */
+case class GlobalLimitAndOffsetExec(
+    limit: Int,
+    offset: Int,
+    child: SparkPlan) extends BaseLimitExec {
+
+  override def requiredChildDistribution: List[Distribution] = AllTuples :: Nil
+
+  override def outputPartitioning: Partitioning = child.outputPartitioning
+
+  override def outputOrdering: Seq[SortOrder] = child.outputOrdering
+
+  override def doExecute(): RDD[InternalRow] = {
+    val rdd = child.execute().mapPartitions { iter => iter.take(limit + offset)}
+    val skips = rdd.take(offset)
 
 Review comment:
   Yes, but if the limit was a huge number, it still will throw OOM.
   This PR only follows the implement of `BaseLimitExec` https://github.com/apache/spark/blob/14ca8d326fcc5035da5b7a99772aacff8edad163/sql/core/src/main/scala/org/apache/spark/sql/execution/limit.scala#L109
   If this is an issue, `GlobalLimitExec` and `LocalLimitExec` need to resolve too.

----------------------------------------------------------------
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