[ 
https://issues.apache.org/jira/browse/PHOENIX-2827?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15537109#comment-15537109
 ] 

ASF GitHub Bot commented on PHOENIX-2827:
-----------------------------------------

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

    https://github.com/apache/phoenix/pull/213#discussion_r81419580
  
    --- 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);
    +        int offsetValue = 0;
    +        if (offset != null){
    +            offsetValue = RexLiteral.intValue(offset);
    +        }
             if (plan.getLimit() == null) {
    -            return plan.limit(fetchValue);
    +            return plan.limit(fetchValue, offsetValue);
             }
             
             return new ClientScanPlan(plan.getContext(), plan.getStatement(), 
                     implementor.getTableMapping().getTableRef(), 
RowProjector.EMPTY_PROJECTOR, 
    -                fetchValue, null, null, OrderBy.EMPTY_ORDER_BY, plan);
    +                fetchValue, offsetValue, null, OrderBy.EMPTY_ORDER_BY, 
plan);
    --- End diff --
    
    Since either of them could be null, Boolean objects should be used instead 
of primitive boolean type.


> Support OFFSET in Calcite-Phoenix
> ---------------------------------
>
>                 Key: PHOENIX-2827
>                 URL: https://issues.apache.org/jira/browse/PHOENIX-2827
>             Project: Phoenix
>          Issue Type: Task
>            Reporter: Maryann Xue
>            Assignee: Eric Lomore
>              Labels: calcite
>




--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to