db2 sql parser support hierarchical.

This commit is contained in:
wenshao
2017-04-24 17:52:40 +08:00
parent ff7a6ee52e
commit 7f75fb3eb9
4 changed files with 100 additions and 10 deletions
@@ -27,26 +27,28 @@ import com.alibaba.druid.sql.visitor.SQLASTVisitor;
public class SQLSelectQueryBlock extends SQLObjectImpl implements SQLSelectQuery {
protected int distionOption;
protected final List<SQLSelectItem> selectList = new ArrayList<SQLSelectItem>();
protected final List<SQLSelectItem> selectList = new ArrayList<SQLSelectItem>();
protected SQLTableSource from;
protected SQLExprTableSource into;
protected SQLExpr where;
// for oracle & oceanbase
protected SQLExpr startWith;
protected SQLExpr connectBy;
protected boolean prior = false;
protected boolean noCycle = false;
protected SQLOrderBy orderBySiblings;
protected SQLSelectGroupByClause groupBy;
protected SQLOrderBy orderBy;
protected boolean parenthesized = false;
protected boolean forUpdate = false;
protected boolean noWait = false;
protected boolean parenthesized = false;
protected boolean forUpdate = false;
protected boolean noWait = false;
protected SQLExpr waitTime;
protected SQLLimit limit;
// for oracle & oceanbase
protected SQLExpr startWith;
protected SQLExpr connectBy;
protected boolean prior = false;
protected boolean noCycle = false;
public SQLSelectQueryBlock(){
}
@@ -100,6 +102,17 @@ public class SQLSelectQueryBlock extends SQLObjectImpl implements SQLSelectQuery
this.orderBy = orderBy;
}
public SQLOrderBy getOrderBySiblings() {
return orderBySiblings;
}
public void setOrderBySiblings(SQLOrderBy orderBySiblings) {
if (orderBySiblings != null) {
orderBySiblings.setParent(this);
}
this.orderBySiblings = orderBySiblings;
}
public int getDistionOption() {
return this.distionOption;
}
@@ -76,6 +76,8 @@ public class DB2SelectParser extends SQLSelectParser {
parseWhere(queryBlock);
parseHierachical(queryBlock);
parseGroupBy(queryBlock);
if (lexer.token() == Token.ORDER) {
@@ -1089,6 +1089,8 @@ public class SQLASTOutputVisitor extends SQLASTVisitorAdapter implements Paramet
where.accept(this);
}
printHierarchical(x);
if (x.getGroupBy() != null) {
println();
x.getGroupBy().accept(this);