improved sql parser.

This commit is contained in:
wenshao
2017-06-29 15:19:57 +08:00
parent 2f6e406e33
commit bdbc39ec3c
39 changed files with 963 additions and 185 deletions
@@ -128,7 +128,7 @@ public class ParameterizedOutputVisitorUtils {
if (parent instanceof SQLDataType //
|| parent instanceof SQLColumnDefinition //
|| parent instanceof SQLServerTop //
//|| parent instanceof SQLAssignItem //
|| parent instanceof SQLAggregateExpr //
|| parent instanceof SQLSelectOrderByItem //
) {
return false;
@@ -1484,7 +1484,14 @@ public class SQLASTOutputVisitor extends SQLASTVisitorAdapter implements Paramet
}
if (tableMapping != null && expr instanceof SQLName) {
String tableName = expr.toString();
String tableName;
if (expr instanceof SQLIdentifierExpr) {
tableName = ((SQLIdentifierExpr) expr).normalizedName();
} else if (expr instanceof SQLPropertyExpr) {
tableName = ((SQLPropertyExpr) expr).normalizedName();
} else {
tableName = expr.toString();
}
String destTableName = tableMapping.get(tableName);
if (destTableName == null) {
@@ -3841,8 +3848,7 @@ public class SQLASTOutputVisitor extends SQLASTVisitorAdapter implements Paramet
}
if (x.getSubPartitions().size() > 0) {
println();
print('(');
print(" (");
incrementIndent();
for (int i = 0; i < x.getSubPartitions().size(); ++i) {
if (i != 0) {
@@ -3883,8 +3889,7 @@ public class SQLASTOutputVisitor extends SQLASTVisitorAdapter implements Paramet
printPartitionsCountAndSubPartitions(x);
println();
print('(');
print(" (");
incrementIndent();
for (int i = 0, size = x.getPartitions().size(); i < size; ++i) {
if (i != 0) {
@@ -4052,6 +4057,12 @@ public class SQLASTOutputVisitor extends SQLASTVisitorAdapter implements Paramet
x.getValues().accept(this);
}
SQLName tableSpace = x.getTableSpace();
if (tableSpace != null) {
print0(ucase ? " TABLESPACE " : " tablespace ");
tableSpace.accept(this);
}
return false;
}
@@ -4414,6 +4425,11 @@ public class SQLASTOutputVisitor extends SQLASTVisitorAdapter implements Paramet
} else if (x.getCompress() == Boolean.TRUE) {
println();
print0(ucase ? "COMPRESS" : "compress");
if (x.getCompressLevel() != null) {
print(' ');
print(x.getCompressLevel());
}
}
if (x.getLogging() == Boolean.TRUE) {