improved sql paser for aliyun analyticdb.

This commit is contained in:
wenshao
2018-05-31 13:51:32 +08:00
parent 9c8b14bd4a
commit ca38876d1e
10 changed files with 444 additions and 1 deletions
@@ -6579,6 +6579,32 @@ public class SQLASTOutputVisitor extends SQLASTVisitorAdapter implements Paramet
return false;
}
@Override
public boolean visit(SQLDumpStatement x) {
List<SQLCommentHint> headHints = x.getHeadHintsDirect();
if (headHints != null) {
for (SQLCommentHint hint : headHints) {
hint.accept(this);
println();
}
}
print0(ucase ? "DUMP DATA " : "dump data ");
if (x.isOverwrite()) {
print0(ucase ? "OVERWRITE " : "overwrite ");
}
SQLExprTableSource into = x.getInto();
if (into != null) {
into.accept(this);
}
x.getSelect().accept(this);
return false;
}
public void print(float value) {
if (this.appender == null) {
return;
@@ -842,4 +842,7 @@ public interface SQLASTVisitor {
boolean visit(SQLWindow x);
void endVisit(SQLWindow x);
boolean visit(SQLDumpStatement x);
void endVisit(SQLDumpStatement x);
}
@@ -1990,7 +1990,6 @@ public class SQLASTVisitorAdapter implements SQLASTVisitor {
}
@Override
public boolean visit(SQLWindow x) {
return true;
@@ -2000,6 +1999,14 @@ public class SQLASTVisitorAdapter implements SQLASTVisitor {
}
@Override
public boolean visit(SQLDumpStatement x) {
return true;
}
public void endVisit(SQLDumpStatement x) {
}
public final boolean isEnabled(VisitorFeature feature) {
return VisitorFeature.isEnabled(this.features, feature);
@@ -2515,4 +2515,23 @@ public class SchemaStatVisitor extends SQLASTVisitorAdapter {
}
return false;
}
public boolean visit(SQLDumpStatement x) {
if (repository != null
&& x.getParent() == null) {
repository.resolve(x);
}
final SQLExprTableSource into = x.getInto();
if (into != null) {
into.accept(this);
}
final SQLSelect select = x.getSelect();
if (select != null) {
select.accept(this);
}
return false;
}
}