improved odps parser support

This commit is contained in:
高铁
2021-06-28 20:58:45 +08:00
parent 9ec736dde8
commit 6f002b81a9
3 changed files with 17 additions and 1 deletions
@@ -290,7 +290,13 @@ public class OdpsOutputVisitor extends HiveOutputVisitor implements OdpsASTVisit
@Override
public boolean visit(SQLJoinTableSource x) {
x.getLeft().accept(this);
SQLTableSource left = x.getLeft();
left.accept(this);
if (left.hasAfterComment() && isPrettyFormat()) {
println();
printlnComment(left.getAfterCommentsDirect());
}
if (x.getJoinType() == JoinType.COMMA) {
print(',');
@@ -3032,6 +3032,10 @@ public class SQLExprParser extends SQLParser {
public SQLExpr orRest(SQLExpr expr) {
for (;;) {
if (lexer.token == Token.OR) {
if (lexer.isKeepComments() && lexer.hasComment()) {
expr.addAfterComment(lexer.readAndResetComments());
}
lexer.nextToken();
SQLExpr rightExp = xor();
@@ -1132,6 +1132,12 @@ public class SQLSelectParser extends SQLParser {
}
public SQLTableSource parseTableSourceRest(SQLTableSource tableSource) {
if (lexer.hasComment()
&& lexer.isKeepComments()
&& !(tableSource instanceof SQLSubqueryTableSource)) {
tableSource.addAfterComment(lexer.readAndResetComments());
}
if (tableSource.getAlias() == null || tableSource.getAlias().length() == 0) {
Token token = lexer.token;
long hash;