improved odps support

This commit is contained in:
高铁
2021-09-05 13:21:04 +08:00
parent 69d9f6f89b
commit 1403ee6817
5 changed files with 290 additions and 5 deletions
@@ -2198,10 +2198,25 @@ public class Lexer {
pos++;
bufPos++;
boolean ident = false;
for (;;) {
ch = charAt(++pos);
if (isEOF()) {
pos--;
bufPos--;
break;
}
if (ch == '}') {
if (ch == '}' && !ident) {
if (isIdentifierChar(charAt(pos + 1))) {
bufPos++;
ident = true;
continue;
}
break;
}
if (ident && isWhitespace(ch)) {
break;
}
@@ -2209,7 +2224,7 @@ public class Lexer {
continue;
}
if (ch != '}') {
if (ch != '}' && !ident) {
throw new ParserException("syntax error. " + info());
}
++pos;
@@ -2226,7 +2241,7 @@ public class Lexer {
}
stringVal = addSymbol();
token = Token.VARIANT;
token = ident ? IDENTIFIER : Token.VARIANT;
return;
} else if (c1 == '$' && charAt(pos + 2) == '{') {
pos += 2;
@@ -2789,12 +2804,30 @@ public class Lexer {
&& !(ch == 'b' && bufPos == 1 && charAt(pos - 1) == '0' && dbType != DbType.odps)
) {
bufPos++;
boolean brace = false;
for (;;) {
char c0 = ch;
ch = charAt(++pos);
if (isEOF()) {
break;
}
if (!isIdentifierChar(ch)) {
if (ch == '(' || ch == ')' && c0 > 256) {
if (ch == '{' && charAt(pos - 1) == '$' && !brace) {
bufPos++;
brace = true;
continue;
}
if (ch == '}' && brace) {
bufPos++;
brace = false;
continue;
}
if ((ch == '(' || ch == ')')
&& c0 > 256) {
bufPos++;
continue;
}
@@ -6511,7 +6511,7 @@ public class SQLASTOutputVisitor extends SQLASTVisitorAdapter implements Paramet
}
SQLName changeOwnerTo = x.getChangeOwnerTo();
if (to != null) {
if (changeOwnerTo != null) {
print0(ucase ? " CHANGEOWNER TO " : " changeowner to ");
printExpr(changeOwnerTo);
}
@@ -6,6 +6,7 @@ import com.alibaba.druid.sql.ast.SQLStatement;
import com.alibaba.druid.sql.ast.statement.*;
import com.alibaba.druid.sql.dialect.hive.ast.HiveInsertStatement;
import com.alibaba.druid.sql.dialect.hive.ast.HiveMultiInsertStatement;
import com.alibaba.druid.sql.dialect.hive.stmt.HiveLoadDataStatement;
import com.alibaba.druid.sql.dialect.odps.ast.OdpsDeclareVariableStatement;
import com.alibaba.druid.sql.dialect.odps.ast.OdpsQueryAliasStatement;
import com.alibaba.druid.sql.parser.*;
@@ -97,6 +98,8 @@ public class SqlTypeUDF extends UDF {
? SQLType.INSERT_OVERWRITE_VALUES
: SQLType.INSERT_INTO_VALUES;
}
} else if (stmt instanceof HiveLoadDataStatement) {
sqlType = SQLType.LOAD;
} else if (stmt instanceof SQLUpdateStatement) {
sqlType = SQLType.UPDATE;
} else if (stmt instanceof SQLDeleteStatement) {