mirror of
https://github.com/alibaba/druid.git
synced 2023-03-04 19:17:16 +00:00
improved odps sql parser, support ARRAY/MAP/STRUCT dataType, for issue #2145
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user