cloud-fan commented on a change in pull request #34291:
URL: https://github.com/apache/spark/pull/34291#discussion_r733398197
##########
File path:
sql/core/src/main/scala/org/apache/spark/sql/execution/datasources/v2/V2ScanRelationPushDown.scala
##########
@@ -225,6 +225,38 @@ object V2ScanRelationPushDown extends Rule[LogicalPlan]
with PredicateHelper {
withProjection
}
+ def applyLimit(plan: LogicalPlan): LogicalPlan = plan.transform {
+ case globalLimit @ Limit(IntegerLiteral(limitValue), child) => child match
{
+ case DataSourceV2ScanRelation(_, scan, _) =>
+ pushDownLimit(globalLimit, scan, limitValue)
+ case Project(_, DataSourceV2ScanRelation(_, scan, _)) =>
+ pushDownLimit (globalLimit, scan, limitValue)
+ case Aggregate(_, _, DataSourceV2ScanRelation(_, scan, _))
+ if (scan.isInstanceOf[V1ScanWrapper] &&
+ scan.asInstanceOf[V1ScanWrapper].pushedAggregate.nonEmpty) =>
+ pushDownLimit (globalLimit, scan, limitValue)
+ case _ => globalLimit
+ }
+ }
+
+ private def pushDownLimit(plan: LogicalPlan, scan: Scan, limitValue: Int):
LogicalPlan = {
+ val supportsPushDownLimit = scan match {
Review comment:
I'm confused. Why do we repeat the code of `PushDownUtils.pushLimit`
here? Shall we let `PushDownUtils.pushLimit` return boolean 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.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]