Github user amansinha100 commented on a diff in the pull request:

    https://github.com/apache/drill/pull/1096#discussion_r171480227
  
    --- Diff: 
exec/java-exec/src/main/java/org/apache/drill/exec/planner/logical/DrillPushLimitToScanRule.java
 ---
    @@ -55,18 +62,21 @@ public void onMatch(RelOptRuleCall call) {
         }
       };
     
    -  public static DrillPushLimitToScanRule LIMIT_ON_PROJECT =
    -      new DrillPushLimitToScanRule(
    -          RelOptHelper.some(DrillLimitRel.class, RelOptHelper.some(
    -              DrillProjectRel.class, 
RelOptHelper.any(DrillScanRel.class))),
    -          "DrillPushLimitToScanRule_LimitOnProject") {
    +  public static DrillPushLimitToScanRule LIMIT_ON_PROJECT = new 
DrillPushLimitToScanRule(
    +      RelOptHelper.some(DrillLimitRel.class, 
RelOptHelper.any(DrillProjectRel.class)), 
"DrillPushLimitToScanRule_LimitOnProject") {
         @Override
         public boolean matches(RelOptRuleCall call) {
           DrillLimitRel limitRel = call.rel(0);
    -      DrillScanRel scanRel = call.rel(2);
    -      // For now only applies to Parquet. And pushdown only apply limit 
but not offset,
    +      DrillProjectRel projectRel = call.rel(1);
    +      // pushdown only apply limit but not offset,
           // so if getFetch() return null no need to run this rule.
    -      if (scanRel.getGroupScan().supportsLimitPushdown() && 
(limitRel.getFetch() != null)) {
    --- End diff --
    
    One implication of this is suppose the underlying Scan does not support 
Limit pushdown, you could end up with a plan `Scan->Limit->Project->Limit`  
where the Limit above the Scan is redundant (assume that there is no FLATTEN in 
this query).  Can this be avoided ? 


---

Reply via email to