mirror of
https://github.com/alibaba/druid.git
synced 2023-03-04 19:17:16 +00:00
bug fixed for refactor
This commit is contained in:
@@ -24,7 +24,7 @@ public class HiveCreateTableParser extends SQLCreateTableParser {
|
||||
public SQLCreateTableStatement parseCrateTable(boolean acceptCreate) {
|
||||
HiveCreateTableStatement stmt = (HiveCreateTableStatement) super.parseCrateTable(acceptCreate);
|
||||
|
||||
if (lexer.token() == Token.PARTITIONED) {
|
||||
if (identifierEquals("PARTITIONED")) {
|
||||
lexer.nextToken();
|
||||
accept(Token.BY);
|
||||
accept(Token.LPAREN);
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
package com.alibaba.druid.sql.dialect.hive.parser;
|
||||
|
||||
import com.alibaba.druid.sql.parser.Lexer;
|
||||
import com.alibaba.druid.sql.parser.ParserException;
|
||||
import com.alibaba.druid.sql.parser.SQLExprParser;
|
||||
|
||||
|
||||
public class HiveExprParser extends SQLExprParser {
|
||||
public HiveExprParser(String sql) throws ParserException{
|
||||
super(new HiveLexer(sql));
|
||||
this.lexer.nextToken();
|
||||
}
|
||||
|
||||
public HiveExprParser(Lexer lexer){
|
||||
super(lexer);
|
||||
}
|
||||
}
|
||||
@@ -83,9 +83,6 @@ public class HiveLexer extends Lexer {
|
||||
map.put("ANY", Token.ANY);
|
||||
|
||||
map.put("WITH", Token.WITH);
|
||||
map.put("PARTITIONED", Token.PARTITIONED);
|
||||
map.put("SHOW", Token.SHOW);
|
||||
map.put("TABLES", Token.TABLES);
|
||||
|
||||
DEFAULT_SQL_SERVER_KEYWORDS = new Keywords(map);
|
||||
}
|
||||
|
||||
@@ -25,10 +25,10 @@ public class HiveStatementParser extends SQLStatementParser {
|
||||
}
|
||||
|
||||
public boolean parseStatementListDialect(List<SQLStatement> statementList) {
|
||||
if (lexer.token() == Token.SHOW) {
|
||||
if (identifierEquals("SHOW")) {
|
||||
lexer.nextToken();
|
||||
|
||||
if (lexer.token() == Token.TABLES) {
|
||||
if (identifierEquals("TABLES")) {
|
||||
lexer.nextToken();
|
||||
|
||||
HiveShowTablesStatement stmt = new HiveShowTablesStatement();
|
||||
@@ -41,7 +41,7 @@ public class HiveStatementParser extends SQLStatementParser {
|
||||
return true;
|
||||
}
|
||||
|
||||
throw new ParserException("TODO " + lexer.token());
|
||||
throw new ParserException("TODO " + lexer.info());
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -11,7 +11,8 @@ import com.alibaba.druid.sql.parser.Token;
|
||||
|
||||
public class PGExprParser extends SQLExprParser{
|
||||
public PGExprParser(String sql) throws ParserException{
|
||||
super(sql);
|
||||
super(new PGLexer(sql));
|
||||
this.lexer.nextToken();
|
||||
}
|
||||
|
||||
public PGExprParser(Lexer lexer){
|
||||
|
||||
@@ -185,6 +185,10 @@ public class Lexer {
|
||||
public final Token token() {
|
||||
return token;
|
||||
}
|
||||
|
||||
public String info() {
|
||||
return this.token + " " + this.stringVal();
|
||||
}
|
||||
|
||||
public final void nextToken() {
|
||||
sp = 0;
|
||||
|
||||
@@ -184,6 +184,13 @@ public class SQLStatementParser extends SQLParser {
|
||||
statementList.add(stmt);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (identifierEquals("COMMIT")) {
|
||||
SQLStatement stmt = parseCommit();
|
||||
|
||||
statementList.add(stmt);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (lexer.token() == Token.LPAREN) {
|
||||
char mark_ch = lexer.current();
|
||||
@@ -225,6 +232,10 @@ public class SQLStatementParser extends SQLParser {
|
||||
}
|
||||
return stmt;
|
||||
}
|
||||
|
||||
public SQLStatement parseCommit() {
|
||||
throw new ParserException("TODO " + lexer.token() + " " + lexer.stringVal());
|
||||
}
|
||||
|
||||
public SQLUseStatement parseUse() {
|
||||
accept(Token.USE);
|
||||
|
||||
@@ -167,9 +167,6 @@ public enum Token {
|
||||
TOP("TOP"),
|
||||
|
||||
// hive
|
||||
PARTITIONED("PARTITIONED"),
|
||||
SHOW("SHOW"),
|
||||
TABLES("TABLES"),
|
||||
|
||||
EOF,
|
||||
ERROR,
|
||||
|
||||
Reference in New Issue
Block a user