Search in sources :

Example 1 with ParametricType

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;
}
Also used : VarcharType(com.netflix.metacat.common.type.VarcharType) DecimalType(com.netflix.metacat.common.type.DecimalType) RowType(com.netflix.metacat.common.type.RowType) ParametricType(com.netflix.metacat.common.type.ParametricType) CharType(com.netflix.metacat.common.type.CharType) MapType(com.netflix.metacat.common.type.MapType)

Aggregations

CharType (com.netflix.metacat.common.type.CharType)1 DecimalType (com.netflix.metacat.common.type.DecimalType)1 MapType (com.netflix.metacat.common.type.MapType)1 ParametricType (com.netflix.metacat.common.type.ParametricType)1 RowType (com.netflix.metacat.common.type.RowType)1 VarcharType (com.netflix.metacat.common.type.VarcharType)1