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

    https://github.com/apache/phoenix/pull/39#discussion_r25924146
  
    --- Diff: 
phoenix-core/src/main/java/org/apache/phoenix/compile/QueryCompiler.java ---
    @@ -147,21 +169,146 @@ public QueryCompiler(PhoenixStatement statement, 
SelectStatement select, ColumnR
          */
         public QueryPlan compile() throws SQLException{
             SelectStatement select = this.select;
    -        List<Object> binds = statement.getParameters();
    +        QueryPlan plan;
    +        if (isUnionAll()) {
    +            plan = compileUnionAll(select);
    +        } else {
    +            plan = compileSelect(select);
    +        }
    +        return plan;
    +    }
    +
    +    public QueryPlan compileSelect(SelectStatement select) throws 
SQLException{
    +     //   SelectStatement select = this.select;
    +           List<Object> binds = statement.getParameters();
    +           StatementContext context = new StatementContext(statement, 
resolver, scan, sequenceManager);
    +           ColumnResolver resolver;
    +           if (isUnionAll()) {
    +                   resolver = FromCompiler.getResolverForQuery(select, 
statement.getConnection());
    +                   context = new StatementContext(statement, resolver, new 
Scan(), sequenceManager);
    +           } 
    +           if (select.isJoin()) {
    +                   if (isUnionAll()) {
    +                           resolver = 
FromCompiler.getResolverForQuery(select, statement.getConnection());
    +                           select = JoinCompiler.optimize(statement, 
select, resolver);
    +                   }
    +                   else { 
    +                       select = JoinCompiler.optimize(statement, select, 
this.resolver);
    +                   }
    +                   if (this.select != select) {
    +                       ColumnResolver resolver1 = 
FromCompiler.getResolverForQuery(select, statement.getConnection());
    +                       context = new StatementContext(statement, 
resolver1, scan, sequenceManager);
    +                   }
    +                   JoinTable joinTable = JoinCompiler.compile(statement, 
select, context.getResolver());
    +                   return compileJoinQuery(context, binds, joinTable, 
false, false, null);
    +           } else {
    +               return compileSingleQuery(context, select, binds, false, 
true);
    +           }
    +    }
    +
    +    private void checkForOrderByLimitInUnionAllSelect(SelectStatement 
select) throws SQLException {
    +        if (select.getOrderBy() != null && !select.getOrderBy().isEmpty()) 
{
    +            throw new 
SQLExceptionInfo.Builder(SQLExceptionCode.ORDER_BY_IN_UNIONALL_SELECT_NOT_SUPPORTED).setMessage(".").build().buildException();
    +        }
    +        if (select.getLimit() != null) {
    +            throw new 
SQLExceptionInfo.Builder(SQLExceptionCode.LIMIT_IN_UNIONALL_SELECT_NOT_SUPPORTED).setMessage(".").build().buildException();
    +        }
    +    }
    +
    +    private PTable createTempTableForUnionAllResultResolver(QueryPlan 
plan) throws SQLException {
    --- End diff --
    
    The implementation is pretty good, but should be called elsewhere. Please 
refer to the comment below.


---
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 [email protected] or file a JIRA ticket
with INFRA.
---

Reply via email to