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

    https://github.com/apache/phoenix/pull/213#discussion_r81419366
  
    --- Diff: 
phoenix-core/src/main/java/org/apache/phoenix/calcite/rel/PhoenixLimit.java ---
    @@ -76,20 +76,27 @@ public RelOptCost computeSelfCost(RelOptPlanner 
planner, RelMetadataQuery mq) {
         
         @Override 
         public double estimateRowCount(RelMetadataQuery mq) {
    -        double rows = super.estimateRowCount(mq);        
    +        double rows = super.estimateRowCount(mq);
    +        if(offset != null) {
    +            return Math.max(0, Math.min(RexLiteral.intValue(fetch), rows - 
RexLiteral.intValue(offset)));
    +        }
             return Math.min(RexLiteral.intValue(fetch), rows);
         }
     
         @Override
         public QueryPlan implement(PhoenixRelImplementor implementor) {
             QueryPlan plan = implementor.visitInput(0, (PhoenixQueryRel) 
getInput());
             int fetchValue = RexLiteral.intValue(fetch);
    --- End diff --
    
    I believe now that we've enabled offset, "this.fetch" could be also be 
null, which means it should be handled the same way as this.offset now. Could 
you please also add test cases to cover situations like "offset != null" but 
"limit == null"?


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

Reply via email to