cloud-fan commented on code in PR #36295: URL: https://github.com/apache/spark/pull/36295#discussion_r880689282
########## sql/core/src/main/scala/org/apache/spark/sql/execution/datasources/v2/V2ScanRelationPushDown.scala: ########## @@ -419,6 +420,60 @@ object V2ScanRelationPushDown extends Rule[LogicalPlan] with PredicateHelper wit } } + private def pushDownOffset( + plan: LogicalPlan, + offset: Int): (LogicalPlan, Boolean) = plan match { + case operation @ ScanOperation(_, filter, sHolder: ScanBuilderHolder) if filter.isEmpty => + val isPushed = PushDownUtils.pushOffset(sHolder.builder, offset) + if (isPushed) { + sHolder.pushedOffset = Some(offset) + } + (operation, isPushed) + case p: Project => + val (newChild, isPushed) = pushDownOffset(p.child, offset) + (p.withNewChildren(Seq(newChild)), isPushed) + case other => (other, false) + } + + def pushDownOffsets(plan: LogicalPlan): LogicalPlan = plan.transform { Review Comment: I think the code can be much easier to read if we push down limit and offset together. ``` def pushDownLimitAndOffset(plan: LogicalPlan): LogicalPlan = plan.transform { case Limit... case Offset... case LimitAndOffset ... ... } ``` the code should be similar to the plann rule `SpecialLimits` -- 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. To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org 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