Search in sources :

Example 1 with MapParametricType

use of com.facebook.presto.type.MapParametricType in project presto by prestodb.

the class BuiltInTypeAndFunctionNamespaceManager method instantiateParametricType.

private Type instantiateParametricType(TypeSignature signature) {
    List<TypeParameter> parameters = new ArrayList<>();
    for (TypeSignatureParameter parameter : signature.getParameters()) {
        TypeParameter typeParameter = TypeParameter.of(parameter, functionAndTypeManager);
        parameters.add(typeParameter);
    }
    ParametricType parametricType = parametricTypes.get(signature.getBase().toLowerCase(Locale.ENGLISH));
    if (parametricType == null) {
        throw new IllegalArgumentException("Unknown type " + signature);
    }
    if (parametricType instanceof MapParametricType) {
        return ((MapParametricType) parametricType).createType(functionAndTypeManager, parameters);
    }
    Type instantiatedType = parametricType.createType(parameters);
    // checkState(instantiatedType.equalsSignature(signature), "Instantiated parametric type name (%s) does not match expected name (%s)", instantiatedType, signature);
    return instantiatedType;
}
Also used : TypeParameter(com.facebook.presto.common.type.TypeParameter) DecimalParametricType(com.facebook.presto.type.DecimalParametricType) UserDefinedType(com.facebook.presto.common.type.UserDefinedType) OperatorType.tryGetOperatorType(com.facebook.presto.common.function.OperatorType.tryGetOperatorType) VarcharParametricType(com.facebook.presto.type.VarcharParametricType) ParametricType(com.facebook.presto.common.type.ParametricType) CharParametricType(com.facebook.presto.type.CharParametricType) Type(com.facebook.presto.common.type.Type) OperatorType(com.facebook.presto.common.function.OperatorType) MapParametricType(com.facebook.presto.type.MapParametricType) TypeSignatureParameter(com.facebook.presto.common.type.TypeSignatureParameter) ArrayList(java.util.ArrayList) MapParametricType(com.facebook.presto.type.MapParametricType) DecimalParametricType(com.facebook.presto.type.DecimalParametricType) VarcharParametricType(com.facebook.presto.type.VarcharParametricType) ParametricType(com.facebook.presto.common.type.ParametricType) CharParametricType(com.facebook.presto.type.CharParametricType) MapParametricType(com.facebook.presto.type.MapParametricType)

Aggregations

OperatorType (com.facebook.presto.common.function.OperatorType)1 OperatorType.tryGetOperatorType (com.facebook.presto.common.function.OperatorType.tryGetOperatorType)1 ParametricType (com.facebook.presto.common.type.ParametricType)1 Type (com.facebook.presto.common.type.Type)1 TypeParameter (com.facebook.presto.common.type.TypeParameter)1 TypeSignatureParameter (com.facebook.presto.common.type.TypeSignatureParameter)1 UserDefinedType (com.facebook.presto.common.type.UserDefinedType)1 CharParametricType (com.facebook.presto.type.CharParametricType)1 DecimalParametricType (com.facebook.presto.type.DecimalParametricType)1 MapParametricType (com.facebook.presto.type.MapParametricType)1 VarcharParametricType (com.facebook.presto.type.VarcharParametricType)1 ArrayList (java.util.ArrayList)1