private RegressorType() { super(new TypeSignature(NAME)); } }
private UnknownType() { // We never access the native container for UNKNOWN because its null check is always true. // The actual native container type does not matter here. // We choose boolean to represent UNKNOWN because it's the smallest primitive type. super(new TypeSignature(NAME), boolean.class, 1); }
private ModelType() { super(new TypeSignature("Model"), Slice.class); }
public LikePatternType() { super(new TypeSignature(NAME), Regex.class); }
public BingTileType() { super(new TypeSignature(NAME)); }
private VarcharType(int length) { super( new TypeSignature( StandardTypes.VARCHAR, singletonList(TypeSignatureParameter.of((long) length))), Slice.class); if (length < 0) { throw new IllegalArgumentException("Invalid VARCHAR length " + length); } this.length = length; }
DecimalType(int precision, int scale, Class<?> javaType) { super(new TypeSignature(StandardTypes.DECIMAL, buildTypeParameters(precision, scale)), javaType); this.precision = precision; this.scale = scale; }
public FunctionType(List<Type> argumentTypes, Type returnType) { this.signature = new TypeSignature(NAME, typeParameters(argumentTypes, returnType)); this.returnType = requireNonNull(returnType, "returnType is null"); this.argumentTypes = ImmutableList.copyOf(requireNonNull(argumentTypes, "argumentTypes is null")); }
@Override public Type getParameterizedType(String baseTypeName, List<TypeSignatureParameter> typeParameters) { return getType(new TypeSignature(baseTypeName, typeParameters)); }
private static TypeSignature toTypeSignature(ClientTypeSignature signature) { List<TypeSignatureParameter> parameters = signature.getArguments().stream() .map(ClientTypeSignature::legacyClientTypeSignatureParameterToTypeSignatureParameter) .collect(toList()); return new TypeSignature(signature.getRawType(), parameters); }
private CharType(long length) { super( new TypeSignature( StandardTypes.CHAR, singletonList(TypeSignatureParameter.of(length))), Slice.class); if (length < 0 || length > MAX_LENGTH) { throw new PrestoException(INVALID_FUNCTION_ARGUMENT, format("CHAR length scale must be in range [0, %s]", MAX_LENGTH)); } this.length = (int) length; }
@JsonCreator public QuantileDigestType(Type type) { super(new TypeSignature(StandardTypes.QDIGEST, TypeSignatureParameter.of(type.getTypeSignature())), Slice.class); this.type = type; }
public ArrayType(Type elementType) { super(new TypeSignature(ARRAY, TypeSignatureParameter.of(elementType.getTypeSignature())), Block.class); this.elementType = requireNonNull(elementType, "elementType is null"); }
public ClassifierType(Type type) { super(new TypeSignature(ClassifierParametricType.NAME, TypeSignatureParameter.of(type.getTypeSignature()))); checkArgument(type.isComparable(), "type must be comparable"); labelType = type; }
private static TypeSignature makeSignature(List<Field> fields) { int size = fields.size(); if (size == 0) { throw new IllegalArgumentException("Row type must have at least 1 field"); } List<TypeSignatureParameter> parameters = fields.stream() .map(field -> TypeSignatureParameter.of(new NamedTypeSignature(field.getName().map(name -> new RowFieldName(name, false)), field.getType().getTypeSignature()))) .collect(Collectors.toList()); return new TypeSignature(ROW, parameters); }
public static TypeSignature applyBoundVariables(TypeSignature typeSignature, BoundVariables boundVariables) { String baseType = typeSignature.getBase(); if (boundVariables.containsTypeVariable(baseType)) { checkState(typeSignature.getParameters().isEmpty(), "Type parameters cannot have parameters"); return boundVariables.getTypeVariable(baseType).getTypeSignature(); } List<TypeSignatureParameter> parameters = typeSignature.getParameters().stream() .map(typeSignatureParameter -> applyBoundVariables(typeSignatureParameter, boundVariables)) .collect(toList()); return new TypeSignature(baseType, parameters); }
@Override public Type getParameterizedType(String baseTypeName, List<TypeSignatureParameter> typeParameters) { return getType(new TypeSignature(baseTypeName, typeParameters)); }
private TypeSignature varchar() { return new TypeSignature(StandardTypes.VARCHAR, TypeSignatureParameter.of(VarcharType.UNBOUNDED_LENGTH)); }
private TypeSignature decimal(String precisionVariable, String scaleVariable) { return new TypeSignature(StandardTypes.DECIMAL, ImmutableList.of( TypeSignatureParameter.of(precisionVariable), TypeSignatureParameter.of(scaleVariable))); }
private static Type generateType(Symbol symbol) { String typeName = Splitter.on('_').limit(2).splitToList(symbol.getName()).get(1); return METADATA.getType(new TypeSignature(typeName, ImmutableList.of())); } }