feat: 给global in语法补充多global not in 的逻辑处理

This commit is contained in:
kanlon
2022-08-30 08:57:07 +08:00
committed by 温绍锦
parent ba7f0b554f
commit ec6c5b3ab0
2 changed files with 15 additions and 4 deletions
@@ -3036,6 +3036,11 @@ public class SQLExprParser extends SQLParser {
if (lexer.token == Token.GLOBAL) {
global = true;
lexer.nextToken();
// global not in logic
if (lexer.token == Token.NOT) {
lexer.nextToken();
return notRationalRest(expr, true);
}
}
if (lexer.token == Token.IN) {
@@ -3729,12 +3734,12 @@ public class SQLExprParser extends SQLParser {
break;
case NOT:
lexer.nextToken();
expr = notRationalRest(expr);
expr = notRationalRest(expr, false);
break;
case BANG:
if (dbType == DbType.odps) {
lexer.nextToken();
expr = notRationalRest(expr);
expr = notRationalRest(expr, false);
}
break;
case BETWEEN:
@@ -3894,7 +3899,7 @@ public class SQLExprParser extends SQLParser {
return expr;
}
public SQLExpr notRationalRest(SQLExpr expr) {
public SQLExpr notRationalRest(SQLExpr expr, boolean global) {
switch (lexer.token) {
case LIKE:
lexer.nextTokenValue();
@@ -3953,6 +3958,7 @@ public class SQLExprParser extends SQLParser {
inSubQueryExpr.setNot(true);
inSubQueryExpr.setExpr(inListExpr.getExpr());
inSubQueryExpr.setSubQuery(((SQLQueryExpr) targetExpr).getSubQuery());
inSubQueryExpr.setGlobal(global);
expr = inSubQueryExpr;
}
}
@@ -4547,6 +4553,7 @@ public class SQLExprParser extends SQLParser {
return charType;
}
@Override
public void accept(Token token) {
if (lexer.token == token) {
lexer.nextToken();
@@ -4327,7 +4327,11 @@ public class SQLASTOutputVisitor extends SQLASTVisitorAdapter implements Paramet
public boolean visit(SQLInSubQueryExpr x) {
x.getExpr().accept(this);
if (x.isNot()) {
print0(ucase ? " NOT IN (" : " not in (");
if (x.isGlobal()) {
print0(ucase ? " GLOBAL NOT IN (" : " global not in (");
} else {
print0(ucase ? " NOT IN (" : " not in (");
}
} else {
if (x.isGlobal()) {
print0(ucase ? " GLOBAL IN (" : " global in (");