mirror of
https://github.com/alibaba/druid.git
synced 2023-03-04 19:17:16 +00:00
improved hive parser, fix #4248
This commit is contained in:
@@ -970,13 +970,17 @@ public class SQLExprParser extends SQLParser {
|
||||
lexer.nextToken();
|
||||
break;
|
||||
case BANG:
|
||||
lexer.nextToken();
|
||||
sqlExpr = new SQLUnaryExpr(SQLUnaryOperator.Not
|
||||
, primary());
|
||||
break;
|
||||
case BANGBANG: {
|
||||
if (dbType == DbType.hive) {
|
||||
throw new ParserException(lexer.info());
|
||||
}
|
||||
lexer.nextToken();
|
||||
SQLExpr bangExpr = primary();
|
||||
sqlExpr = new SQLUnaryExpr(SQLUnaryOperator.Not, bangExpr);
|
||||
sqlExpr = new SQLUnaryExpr(SQLUnaryOperator.Not
|
||||
, primary());
|
||||
break;
|
||||
}
|
||||
case BANG_TILDE: {
|
||||
@@ -4606,6 +4610,17 @@ public class SQLExprParser extends SQLParser {
|
||||
} else {
|
||||
SQLExpr expr = expr();
|
||||
|
||||
if (lexer.token == Token.COLON) {
|
||||
if (dbType == DbType.hive || dbType == DbType.odps) {
|
||||
Lexer.SavePoint mark = lexer.mark();
|
||||
lexer.nextToken();
|
||||
String str = expr.toString() + ':';
|
||||
str += lexer.numberString();
|
||||
lexer.nextToken();
|
||||
expr = new SQLIdentifierExpr(str);
|
||||
}
|
||||
}
|
||||
|
||||
if (lexer.token == Token.COMMA && DbType.postgresql == dbType) {
|
||||
SQLListExpr listExpr = new SQLListExpr();
|
||||
listExpr.addItem(expr);
|
||||
|
||||
@@ -2051,6 +2051,11 @@ public class SQLStatementParser extends SQLParser {
|
||||
SQLAlterTableSetLifecycle setLifecycle = new SQLAlterTableSetLifecycle();
|
||||
setLifecycle.setLifecycle(this.exprParser.primary());
|
||||
stmt.addItem(setLifecycle);
|
||||
} else if (lexer.identifierEquals(Constants.LOCATION)) {
|
||||
lexer.nextToken();
|
||||
SQLAlterTableSetLocation setLocation = new SQLAlterTableSetLocation();
|
||||
setLocation.setLocation(this.exprParser.primary());
|
||||
stmt.addItem(setLocation);
|
||||
} else if (lexer.identifierEquals(FnvHash.Constants.TBLPROPERTIES)) {
|
||||
lexer.nextToken();
|
||||
SQLAlterTableSetOption setOption = new SQLAlterTableSetOption();
|
||||
|
||||
Reference in New Issue
Block a user