[
https://issues.apache.org/jira/browse/PHOENIX-1580?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14390765#comment-14390765
]
Maryann Xue commented on PHOENIX-1580:
--------------------------------------
And didn't you by any chance find it weird yourself that the AST structure is
inconsistent with the grammar defined in the lexer?
{code}
@@ -686,6 +695,36 @@ public class ParseNodeFactory {
statement.hasSequence());
}
+ public SelectStatement select(List<SelectStatement> statements,
List<OrderByNode> orderBy, LimitNode limit, int bindCount, boolean isAggregate)
{
+ boolean isUnion = statements.size() > 1;
+ boolean hasSequence = false;
+ for (int i = 0; !hasSequence && i < statements.size(); i++) {
+ hasSequence = statements.get(i).hasSequence();
+ }
+ if (isUnion) {
+ if (orderBy != null || limit != null) {
+ // Push ORDER BY and LIMIT into sub selects and set
isAggregate correctly
+ for (int i = 0; i < statements.size(); i++) {
+ SelectStatement statement = statements.get(i);
+ statements.set(i, SelectStatement.create(statement,
orderBy, limit, isAggregate || statement.isAggregate()));
+ }
+ }
+ // Outer SELECT that does union will never be an aggregate
+ isAggregate = false;
+ List<SelectStatement> stmts = new ArrayList<>();
+ for (int i= 1; i<statements.size(); i++) {
+ stmts.add(statements.get(i));
+ }
+ SelectStatement statement = statements.get(0);
+ return select(statement.getFrom(), statement.getHint(),
statement.isDistinct(), statement.getSelect(), statement.getWhere(),
statement.getGroupBy(),
+ statement.getHaving(), orderBy, limit, bindCount,
isAggregate || statement.isAggregate(), hasSequence, stmts);
+ } else {
+ SelectStatement statement = statements.get(0);
+ return select(statement.getFrom(), statement.getHint(),
statement.isDistinct(), statement.getSelect(), statement.getWhere(),
statement.getGroupBy(),
+ statement.getHaving(), orderBy, limit, bindCount,
isAggregate || statement.isAggregate(), hasSequence);
+ }
+ }
+
{code}
> Support UNION ALL
> -----------------
>
> Key: PHOENIX-1580
> URL: https://issues.apache.org/jira/browse/PHOENIX-1580
> Project: Phoenix
> Issue Type: Bug
> Reporter: Alicia Ying Shu
> Assignee: Alicia Ying Shu
> Attachments: PHOENIX-1580-grammar.patch, Phoenix-1580-v1.patch,
> phoenix-1580-v1-wipe.patch, phoenix-1580.patch, unionall-wipe.patch
>
>
> Select * from T1
> UNION ALL
> Select * from T2
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)