improved odps sql parser, support ARRAY/MAP/STRUCT dataType, for issue #2145

This commit is contained in:
wenshao
2017-12-02 12:50:06 +08:00
parent fd2ba2a290
commit 569c50977a
10 changed files with 701 additions and 1 deletions
@@ -6041,4 +6041,39 @@ public class SQLASTOutputVisitor extends SQLASTVisitorAdapter implements Paramet
return false;
}
@Override
public boolean visit(SQLArrayDataType x) {
print0(ucase ? "ARRAY<" : "array<");
x.getComponentType().accept(this);
print('>');
return false;
}
@Override
public boolean visit(SQLMapDataType x) {
print0(ucase ? "MAP<" : "map<");
x.getKeyType().accept(this);
print0(", ");
x.getValueType().accept(this);
print('>');
return false;
}
@Override
public boolean visit(SQLStructDataType x) {
print0(ucase ? "STRUCT<" : "struct<");
printAndAccept(x.getFields(), ", ");
print('>');
return false;
}
@Override
public boolean visit(SQLStructDataType.Field x) {
x.getName().accept(this);
print(':');
x.getDataType().accept(this);
print('>');
return false;
}
}
@@ -802,4 +802,15 @@ public interface SQLASTVisitor {
boolean visit(SQLExternalRecordFormat x);
void endVisit(SQLExternalRecordFormat x);
boolean visit(SQLArrayDataType x);
void endVisit(SQLArrayDataType x);
boolean visit(SQLMapDataType x);
void endVisit(SQLMapDataType x);
boolean visit(SQLStructDataType x);
void endVisit(SQLStructDataType x);
boolean visit(SQLStructDataType.Field x);
void endVisit(SQLStructDataType.Field x);
}
@@ -1874,6 +1874,46 @@ public class SQLASTVisitorAdapter implements SQLASTVisitor {
}
@Override
public boolean visit(SQLArrayDataType x) {
return true;
}
@Override
public void endVisit(SQLArrayDataType x) {
}
@Override
public boolean visit(SQLMapDataType x) {
return true;
}
@Override
public void endVisit(SQLMapDataType x) {
}
@Override
public boolean visit(SQLStructDataType x) {
return true;
}
@Override
public void endVisit(SQLStructDataType x) {
}
@Override
public boolean visit(SQLStructDataType.Field x) {
return true;
}
@Override
public void endVisit(SQLStructDataType.Field x) {
}
public final boolean isEnabled(VisitorFeature feature) {
return VisitorFeature.isEnabled(this.features, feature);
}