use of com.alibaba.druid.sql.dialect.odps.ast.OdpsRemoveStatisticStatement in project druid by alibaba.
the class OdpsStatementParser method parseStatementListDialect.
public boolean parseStatementListDialect(List<SQLStatement> statementList) {
if (lexer.token() == Token.FROM) {
SQLStatement stmt = this.parseInsert();
statementList.add(stmt);
return true;
}
if (identifierEquals("ANALYZE")) {
lexer.nextToken();
accept(Token.TABLE);
OdpsAnalyzeTableStatement stmt = new OdpsAnalyzeTableStatement();
SQLName table = this.exprParser.name();
stmt.setTable(table);
if (lexer.token() == Token.PARTITION) {
lexer.nextToken();
accept(Token.LPAREN);
parseAssignItems(stmt.getPartition(), stmt);
accept(Token.RPAREN);
}
accept(Token.COMPUTE);
acceptIdentifier("STATISTICS");
statementList.add(stmt);
return true;
}
if (identifierEquals("ADD")) {
lexer.nextToken();
if (identifierEquals("STATISTIC")) {
lexer.nextToken();
OdpsAddStatisticStatement stmt = new OdpsAddStatisticStatement();
stmt.setTable(this.exprParser.name());
stmt.setStatisticClause(parseStaticClause());
statementList.add(stmt);
return true;
}
throw new ParserException("TODO " + lexer.token() + " " + lexer.stringVal());
}
if (identifierEquals("REMOVE")) {
lexer.nextToken();
if (identifierEquals("STATISTIC")) {
lexer.nextToken();
OdpsRemoveStatisticStatement stmt = new OdpsRemoveStatisticStatement();
stmt.setTable(this.exprParser.name());
stmt.setStatisticClause(parseStaticClause());
statementList.add(stmt);
return true;
}
throw new ParserException("TODO " + lexer.token() + " " + lexer.stringVal());
}
if (identifierEquals("READ")) {
lexer.nextToken();
OdpsReadStatement stmt = new OdpsReadStatement();
stmt.setTable(this.exprParser.name());
if (lexer.token() == Token.LPAREN) {
lexer.nextToken();
this.exprParser.names(stmt.getColumns(), stmt);
accept(Token.RPAREN);
}
if (lexer.token() == Token.PARTITION) {
lexer.nextToken();
accept(Token.LPAREN);
parseAssignItems(stmt.getPartition(), stmt);
accept(Token.RPAREN);
}
if (lexer.token() == Token.LITERAL_INT) {
stmt.setRowCount(this.exprParser.primary());
}
statementList.add(stmt);
return true;
}
if (identifierEquals("LIST")) {
OdpsListStmt stmt = new OdpsListStmt();
lexer.nextToken();
stmt.setObject(this.exprParser.expr());
statementList.add(stmt);
return true;
}
if (lexer.token() == Token.DESC || identifierEquals("DESCRIBE")) {
OdpsDescStmt stmt = parseDescribe();
statementList.add(stmt);
return true;
}
return false;
}
Aggregations