cloud-fan commented on a change in pull request #34738:
URL: https://github.com/apache/spark/pull/34738#discussion_r760144434



##########
File path: 
sql/core/src/main/scala/org/apache/spark/sql/execution/datasources/v2/V2ScanRelationPushDown.scala
##########
@@ -249,13 +248,25 @@ object V2ScanRelationPushDown extends Rule[LogicalPlan] 
with PredicateHelper {
   def applyLimit(plan: LogicalPlan): LogicalPlan = plan.transform {
     case globalLimit @ Limit(IntegerLiteral(limitValue), child) =>
       child match {
-        case ScanOperation(_, filter, sHolder: ScanBuilderHolder) if 
filter.length == 0 =>
+        case ScanOperation(_, filter, sHolder: ScanBuilderHolder) if 
filter.isEmpty =>
           val limitPushed = PushDownUtils.pushLimit(sHolder.builder, 
limitValue)
           if (limitPushed) {
             sHolder.pushedLimit = Some(limitValue)
           }
           globalLimit
-        case _ => globalLimit
+        case _ =>
+          child transform {

Review comment:
       this looks scary, as we don't know what's between limit and sort, and 
it's dangerous to push down top N.
   
   I think we need to do an exact match: `case Sort(..., ScanOperation...)`




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

Reply via email to