mirror of
https://github.com/alibaba/druid.git
synced 2023-03-04 19:17:16 +00:00
improved odps sql parser for select_distribute_by. issue #1492
This commit is contained in:
@@ -35,7 +35,7 @@ public class OdpsSelectQueryBlock extends SQLSelectQueryBlock {
|
||||
|
||||
protected List<SQLHint> hints;
|
||||
|
||||
protected SQLExpr distributeBy;
|
||||
protected List<SQLExpr> distributeBy = new ArrayList<SQLExpr>();
|
||||
protected List<SQLSelectOrderByItem> sortBy = new ArrayList<SQLSelectOrderByItem>(2);
|
||||
|
||||
public OdpsSelectQueryBlock(){
|
||||
@@ -50,14 +50,10 @@ public class OdpsSelectQueryBlock extends SQLSelectQueryBlock {
|
||||
this.orderBy = orderBy;
|
||||
}
|
||||
|
||||
public SQLExpr getDistributeBy() {
|
||||
public List<SQLExpr> getDistributeBy() {
|
||||
return distributeBy;
|
||||
}
|
||||
|
||||
public void setDistributeBy(SQLExpr distributeBy) {
|
||||
this.distributeBy = distributeBy;
|
||||
}
|
||||
|
||||
public List<SQLSelectOrderByItem> getSortBy() {
|
||||
return sortBy;
|
||||
}
|
||||
|
||||
@@ -85,9 +85,7 @@ public class OdpsSelectParser extends SQLSelectParser {
|
||||
if (lexer.token() == Token.DISTRIBUTE) {
|
||||
lexer.nextToken();
|
||||
accept(Token.BY);
|
||||
SQLExpr distributeBy = this.expr();
|
||||
queryBlock.setDistributeBy(distributeBy);
|
||||
|
||||
this.exprParser.exprList(queryBlock.getDistributeBy(), queryBlock);
|
||||
|
||||
if (identifierEquals("SORT")) {
|
||||
lexer.nextToken();
|
||||
|
||||
@@ -513,10 +513,10 @@ public class OdpsOutputVisitor extends SQLASTOutputVisitor implements OdpsASTVis
|
||||
x.getOrderBy().accept(this);
|
||||
}
|
||||
|
||||
if (x.getDistributeBy() != null) {
|
||||
if (x.getDistributeBy().size() > 0) {
|
||||
println();
|
||||
print0(ucase ? "DISTRIBUTE BY " : "distribute by ");
|
||||
x.getDistributeBy().accept(this);
|
||||
printAndAccept(x.getDistributeBy(), ", ");
|
||||
|
||||
if (!x.getSortBy().isEmpty()) {
|
||||
print0(ucase ? " SORT BY " : " sort by ");
|
||||
|
||||
Reference in New Issue
Block a user