add hive sql parser

This commit is contained in:
温少
2012-02-25 19:54:09 +08:00
parent ded9087df0
commit 4775d9e475
18 changed files with 496 additions and 94 deletions
@@ -15,17 +15,8 @@
*/
package com.alibaba.druid.sql.dialect.sqlserver.parser;
import java.util.List;
import com.alibaba.druid.sql.ast.SQLStatement;
import com.alibaba.druid.sql.ast.statement.SQLSelectStatement;
import com.alibaba.druid.sql.dialect.oracle.ast.stmt.OraclePLSQLCommitStatement;
import com.alibaba.druid.sql.dialect.oracle.parser.OracleDeleteParser;
import com.alibaba.druid.sql.dialect.oracle.parser.OracleSelectParser;
import com.alibaba.druid.sql.parser.Lexer;
import com.alibaba.druid.sql.parser.ParserException;
import com.alibaba.druid.sql.parser.SQLStatementParser;
import com.alibaba.druid.sql.parser.Token;
public class SQLServerStatementParser extends SQLStatementParser {
@@ -38,78 +29,4 @@ public class SQLServerStatementParser extends SQLStatementParser {
super(lexer);
}
@Override
public void parseStatementList(List<SQLStatement> statementList) throws ParserException {
for (;;) {
if (lexer.token() == Token.EOF) {
return;
}
if (lexer.token() == (Token.SEMI)) {
lexer.nextToken();
continue;
}
if (lexer.token() == (Token.SELECT)) {
statementList.add(new SQLSelectStatement(new SQLServerSelectParser(this.lexer).select()));
continue;
}
if (lexer.token() == (Token.UPDATE)) {
statementList.add(parseUpdateStatement());
continue;
}
if (lexer.token() == (Token.CREATE)) {
lexer.nextToken();
// if ((this.tokenList.lookup(1).equals(Token.ViewToken)) ||
// (this.tokenList.lookup(3).equals(Token.ViewToken))
// || (this.tokenList.lookup(4).equals(Token.ViewToken)) ||
// (this.tokenList.lookup(5).equals(Token.ViewToken))) {
// statementList.add(parseCreateView());
// }
//
// if ((this.tokenList.lookup(1).equals(Token.TableToken)) ||
// (this.tokenList.lookup(3).equals(Token.TableToken))) {
// statementList.add(parseOracleCreateTable());
// }
throw new ParserException("TODO");
}
if (lexer.token() == Token.INSERT) {
statementList.add(parseInsert());
continue;
}
if (lexer.token() == (Token.DELETE)) {
statementList.add(new OracleDeleteParser(this.lexer).parseDelete());
continue;
}
if (lexer.token() == (Token.SLASH)) {
lexer.nextToken();
statementList.add(new OraclePLSQLCommitStatement());
continue;
}
if (lexer.token() == Token.ALTER) {
throw new ParserException("TODO");
}
if (lexer.token() == Token.WITH) {
statementList.add(new SQLSelectStatement(new OracleSelectParser(this.lexer).select()));
continue;
}
if (identifierEquals("CALL")) {
statementList.add(this.parseCall());
continue;
}
throw new ParserException("TODO : " + lexer.token() + " " + lexer.stringVal());
}
}
}