mirror of
https://github.com/alibaba/druid.git
synced 2023-03-04 19:17:16 +00:00
improved odps support
This commit is contained in:
@@ -779,6 +779,8 @@ public class Lexer {
|
||||
return SQLType.SHOW_FUNCTIONS;
|
||||
} else if (identifierEquals(FnvHash.Constants.ROLES)) {
|
||||
return SQLType.SHOW_ROLES;
|
||||
} else if (identifierEquals(FnvHash.Constants.ROLE)) {
|
||||
return SQLType.SHOW_ROLE;
|
||||
} else if (identifierEquals(FnvHash.Constants.LABEL)) {
|
||||
return SQLType.SHOW_LABEL;
|
||||
} else if (identifierEquals(FnvHash.Constants.GRANTS)) {
|
||||
@@ -836,6 +838,8 @@ public class Lexer {
|
||||
return SQLType.LIST_TABLES;
|
||||
} else if (identifierEquals(FnvHash.Constants.ROLES)) {
|
||||
return SQLType.LIST_ROLES;
|
||||
} else if (identifierEquals(FnvHash.Constants.TEMPORARY)) {
|
||||
return SQLType.LIST_TEMPORARY_OUTPUT;
|
||||
} else if (identifierEquals("TENANT")) {
|
||||
nextToken();
|
||||
if (identifierEquals(FnvHash.Constants.ROLES)) {
|
||||
|
||||
@@ -3806,11 +3806,20 @@ public class SQLExprParser extends SQLParser {
|
||||
return expr;
|
||||
}
|
||||
break;
|
||||
case RLIKE:
|
||||
case RLIKE: {
|
||||
Lexer.SavePoint mark = lexer.mark();
|
||||
lexer.nextToken();
|
||||
rightExp = bitOr();
|
||||
expr = new SQLBinaryOpExpr(expr, SQLBinaryOperator.RLike, rightExp, getDbType());
|
||||
switch (lexer.token) {
|
||||
case COMMA:
|
||||
lexer.reset(mark);
|
||||
break;
|
||||
default:
|
||||
rightExp = bitOr();
|
||||
expr = new SQLBinaryOpExpr(expr, SQLBinaryOperator.RLike, rightExp, getDbType());
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case IDENTIFIER:
|
||||
long hash = lexer.hash_lower;
|
||||
if (hash == FnvHash.Constants.SOUNDS) {
|
||||
|
||||
@@ -550,6 +550,7 @@ public class SQLParser {
|
||||
case TO:
|
||||
case REFERENCES:
|
||||
case LIKE:
|
||||
case RLIKE:
|
||||
case NULL:
|
||||
case RIGHT:
|
||||
case LEFT:
|
||||
|
||||
@@ -32,6 +32,7 @@ public enum SQLType {
|
||||
SHOW_PARTITIONS,
|
||||
SHOW_CATALOGS,
|
||||
SHOW_FUNCTIONS,
|
||||
SHOW_ROLE,
|
||||
SHOW_ROLES,
|
||||
SHOW_PACKAGE,
|
||||
SHOW_PACKAGES,
|
||||
@@ -58,6 +59,7 @@ public enum SQLType {
|
||||
LIST_TENANT_ROLES,
|
||||
LIST_TRUSTEDPROJECTS,
|
||||
LIST_ACCOUNTPROVIDERS,
|
||||
LIST_TEMPORARY_OUTPUT,
|
||||
WHO, // for analyticdb
|
||||
GRANT,
|
||||
REVOKE,
|
||||
|
||||
@@ -367,6 +367,15 @@ public class ScanSQLTypeV2Test extends TestCase {
|
||||
assertEquals(SQLType.REMOVE, sqlType);
|
||||
}
|
||||
|
||||
public void test_sqlTypeV2_42() throws Exception {
|
||||
String sql = "show role grant \n" +
|
||||
"bsj65s8s6ahf@aliyun.com;";
|
||||
|
||||
Lexer lexer = SQLParserUtils.createLexer(sql, DbType.odps);
|
||||
SQLType sqlType = lexer.scanSQLTypeV2();
|
||||
assertEquals(SQLType.SHOW_ROLE, sqlType);
|
||||
}
|
||||
|
||||
public void test_sqlTypeV2_udf_01() throws Exception {
|
||||
String sql = "ALTER TABLE DWS_ITEM_APPLY2DELIV_LIST_DF\n" +
|
||||
"\tCHANGE COLUMN DELIVERY_PDOTYPE RENAME TO DELIVERY_ORDER_TYPE;";
|
||||
|
||||
Reference in New Issue
Block a user