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

    https://github.com/apache/phoenix/pull/154#discussion_r57269271
  
    --- Diff: 
phoenix-core/src/main/java/org/apache/phoenix/compile/SubselectRewriter.java ---
    @@ -202,14 +204,30 @@ private SelectStatement flatten(SelectStatement 
select, SelectStatement subselec
                     }
                 }
             }
    -        
    +        OffsetNode offset = select.getOffset();
    +        if (offset != null) {
    +            if (offsetRewrite == null) {
    +                offsetRewrite = offset;
    +            } else {
    +                Integer offsetValue = OffsetCompiler.compile(null, select);
    +                Integer offsetValueSubselect = 
OffsetCompiler.compile(null, subselect);
    +                if (offsetValue != null && offsetValueSubselect != null) {
    +                    offsetRewrite = offsetValue < offsetValueSubselect ? 
offset : offsetRewrite;
    +                } else {
    +                    return select;
    +                }
    +            }
    +        }
    +
    --- End diff --
    
    Not sure if this would be correct. Suppose we have "select * from (select a 
from t offset 2 limit 8) offset 3", guess we should return the 5th row instead. 
If you consider the logic is too complicated to optimize at compiletime, you 
can simply quit flattening.


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