use of com.netflix.metacat.common.type.ParametricType in project metacat by Netflix.
the class HiveTypeConverter method fromMetacatType.
@Override
public String fromMetacatType(final Type type) {
if (HiveTypeMapping.getCANONICAL_TO_HIVE().containsKey(type)) {
return HiveTypeMapping.getCANONICAL_TO_HIVE().get(type);
}
if (type instanceof DecimalType | type instanceof CharType | type instanceof VarcharType) {
return type.getDisplayName();
} else if (type.getTypeSignature().getBase().equals(TypeEnum.MAP)) {
final MapType mapType = (MapType) type;
return "map<" + fromMetacatType(mapType.getKeyType()) + "," + fromMetacatType(mapType.getValueType()) + ">";
} else if (type.getTypeSignature().getBase().equals(TypeEnum.ROW)) {
final RowType rowType = (RowType) type;
final String typeString = rowType.getFields().stream().map(this::rowFieldToString).collect(Collectors.joining(","));
return "struct<" + typeString + ">";
} else if (type.getTypeSignature().getBase().equals(TypeEnum.ARRAY)) {
final String typeString = ((ParametricType) type).getParameters().stream().map(this::fromMetacatType).collect(Collectors.joining(","));
return "array<" + typeString + ">";
}
return null;
}
Aggregations