mirror of
https://github.com/alibaba/druid.git
synced 2023-03-04 19:17:16 +00:00
improved odps sql formatter
This commit is contained in:
@@ -278,11 +278,14 @@ public class OdpsOutputVisitor extends SQLASTOutputVisitor implements OdpsASTVis
|
||||
SQLSelectItem selectItem = selectList.get(i);
|
||||
|
||||
if (i != 0) {
|
||||
print(", ");
|
||||
|
||||
printComment(selectList.get(i - 1).getAfterCommentsDirect(), "\n");
|
||||
|
||||
SQLSelectItem preSelectItem = selectList.get(i - 1);
|
||||
if (preSelectItem.hasAfterComment()) {
|
||||
print(' ');
|
||||
printComment(preSelectItem.getAfterCommentsDirect(), "\n");
|
||||
}
|
||||
|
||||
println();
|
||||
print(", ");
|
||||
}
|
||||
|
||||
selectItem.accept(this);
|
||||
@@ -321,14 +324,15 @@ public class OdpsOutputVisitor extends SQLASTOutputVisitor implements OdpsASTVis
|
||||
print(",");
|
||||
} else {
|
||||
println();
|
||||
print(JoinType.toString(x.getJoinType()));
|
||||
printJoinType(x.getJoinType());
|
||||
}
|
||||
print(" ");
|
||||
x.getRight().accept(this);
|
||||
|
||||
if (x.getCondition() != null) {
|
||||
incrementIndent();
|
||||
print(" ON ");
|
||||
println();
|
||||
print("ON ");
|
||||
x.getCondition().accept(this);
|
||||
decrementIndent();
|
||||
}
|
||||
@@ -686,4 +690,16 @@ public class OdpsOutputVisitor extends SQLASTOutputVisitor implements OdpsASTVis
|
||||
print(")");
|
||||
return false;
|
||||
}
|
||||
|
||||
protected void printJoinType(JoinType joinType) {
|
||||
if (joinType.equals(JoinType.LEFT_OUTER_JOIN)) {
|
||||
print("LEFT OUTER JOIN");
|
||||
} else if (joinType.equals(JoinType.RIGHT_OUTER_JOIN)) {
|
||||
print("RIGHT OUTER JOIN");
|
||||
} else if (joinType.equals(JoinType.FULL_OUTER_JOIN)) {
|
||||
print("FULL OUTER JOIN");
|
||||
} else {
|
||||
print(JoinType.toString(joinType));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1283,7 +1283,7 @@ public class SQLASTOutputVisitor extends SQLASTVisitorAdapter implements Printab
|
||||
print(",");
|
||||
} else {
|
||||
println();
|
||||
print(JoinType.toString(x.getJoinType()));
|
||||
printJoinType(x.getJoinType());
|
||||
}
|
||||
print(" ");
|
||||
x.getRight().accept(this);
|
||||
@@ -1311,6 +1311,10 @@ public class SQLASTOutputVisitor extends SQLASTVisitorAdapter implements Printab
|
||||
return false;
|
||||
}
|
||||
|
||||
protected void printJoinType(JoinType joinType) {
|
||||
print(JoinType.toString(joinType));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean visit(ValuesClause x) {
|
||||
print("(");
|
||||
|
||||
Reference in New Issue
Block a user