beliefer commented on a change in pull request #27237: [SPARK-28330][SQL]
Support ANSI SQL: result offset clause in query expression
URL: https://github.com/apache/spark/pull/27237#discussion_r368350682
##########
File path: sql/core/src/main/scala/org/apache/spark/sql/execution/limit.scala
##########
@@ -41,18 +42,28 @@ trait LimitExec extends UnaryExecNode {
* This operator will be used when a logical `Limit` operation is the final
operator in an
* logical plan, which happens when the user is collecting results back to the
driver.
*/
-case class CollectLimitExec(limit: Int, child: SparkPlan) extends LimitExec {
+case class CollectLimitExec(limit: Int, offset: Int, child: SparkPlan) extends
LimitExec {
override def output: Seq[Attribute] = child.output
override def outputPartitioning: Partitioning = SinglePartition
- override def executeCollect(): Array[InternalRow] = child.executeTake(limit)
+ override def executeCollect(): Array[InternalRow] = {
+ if (limit == Limit.INVALID_LIMIT.value) {
+ child.executeCollect().drop(offset)
+ } else {
+ child.executeTake(limit + offset).drop(offset)
Review comment:
I have add check in `CheckAnalysis`.
----------------------------------------------------------------
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]
With regards,
Apache Git Services
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]