private static void validateOperatorSignature(OperatorType operatorType, TypeSignature returnType, List<TypeSignature> argumentTypes, int expectedArgumentCount) { String signature = formatSignature(operatorType, returnType, argumentTypes); checkArgument(!returnType.getBase().equals(UnknownType.NAME), "%s operator return type can not be NULL: %s", operatorType, signature); checkArgument(argumentTypes.size() == expectedArgumentCount, "%s operator must have exactly %s argument: %s", operatorType, expectedArgumentCount, signature); }
private static void validateOperatorSignature(OperatorType operatorType, TypeSignature returnType, List<TypeSignature> argumentTypes, int expectedArgumentCount) { String signature = formatSignature(operatorType, returnType, argumentTypes); checkArgument(!returnType.getBase().equals(UnknownType.NAME), "%s operator return type can not be NULL: %s", operatorType, signature); checkArgument(argumentTypes.size() == expectedArgumentCount, "%s operator must have exactly %s argument: %s", operatorType, expectedArgumentCount, signature); }
public static boolean isStructuralType(Type type) { String baseName = type.getTypeSignature().getBase(); return baseName.equals(StandardTypes.MAP) || baseName.equals(StandardTypes.ARRAY) || baseName.equals(StandardTypes.ROW); }
public static boolean isMapType(Type type) { return type.getTypeSignature().getBase().equals(StandardTypes.MAP); } }
public static boolean isRowType(Type type) { return type.getTypeSignature().getBase().equals(StandardTypes.ROW); }
private static boolean isQuotedType(HiveType type) { return QUOTED_TYPES.contains(type.getTypeSignature().getBase()); } }
private static void validateComparisonOperatorSignature(OperatorType operatorType, TypeSignature returnType, List<TypeSignature> argumentTypes, int expectedArgumentCount) { validateOperatorSignature(operatorType, returnType, argumentTypes, expectedArgumentCount); checkArgument(returnType.getBase().equals(StandardTypes.BOOLEAN), "%s operator must return a BOOLEAN: %s", operatorType, formatSignature(operatorType, returnType, argumentTypes)); }
private static void validateComparisonOperatorSignature(OperatorType operatorType, TypeSignature returnType, List<TypeSignature> argumentTypes, int expectedArgumentCount) { validateOperatorSignature(operatorType, returnType, argumentTypes, expectedArgumentCount); checkArgument(returnType.getBase().equals(StandardTypes.BOOLEAN), "%s operator must return a BOOLEAN: %s", operatorType, formatSignature(operatorType, returnType, argumentTypes)); }
private static ClientTypeSignature toClientTypeSignature(TypeSignature signature) { return new ClientTypeSignature(signature.getBase(), signature.getParameters().stream() .map(Query::toClientTypeSignatureParameter) .collect(toImmutableList())); }
private static ClientTypeSignature toClientTypeSignature(TypeSignature signature) { return new ClientTypeSignature(signature.getBase(), signature.getParameters().stream() .map(Query::toClientTypeSignatureParameter) .collect(toImmutableList())); }
public boolean canBind(Type type) { if (comparableRequired && !type.isComparable()) { return false; } if (orderableRequired && !type.isOrderable()) { return false; } if (variadicBound != null && !type.getTypeSignature().getBase().equals(variadicBound)) { return false; } return true; }
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); }
private static Block serializeObject(BlockBuilder builder, Object value, Type type, String columnName) { switch (type.getTypeSignature().getBase()) { case ARRAY: return serializeList(builder, value, type, columnName); case MAP: return serializeMap(builder, value, type, columnName); default: serializeGeneric(builder, value, type, columnName); } return null; }
private static Row createDescribeInputRow(Parameter parameter, Analysis queryAnalysis) { Type type = queryAnalysis.getCoercion(parameter); if (type == null) { type = UNKNOWN; } return row( new LongLiteral(Integer.toString(parameter.getPosition())), new StringLiteral(type.getTypeSignature().getBase())); }
private static ClientTypeSignature toClientTypeSignature(TypeSignature signature) { return new ClientTypeSignature(signature.getBase(), signature.getParameters().stream() .map(TestFixJsonDataUtils::toClientTypeSignatureParameter) .collect(toImmutableList())); }
private static ClientTypeSignature toClientTypeSignature(TypeSignature signature) { return new ClientTypeSignature(signature.getBase(), signature.getParameters().stream() .map(TestFixJsonDataUtils::toClientTypeSignatureParameter) .collect(toImmutableList())); }
@Test public void testIdentityCast() { TypeRegistry typeManager = new TypeRegistry(); FunctionRegistry registry = new FunctionRegistry(typeManager, new BlockEncodingManager(typeManager), new FeaturesConfig()); Signature exactOperator = registry.getCoercion(HYPER_LOG_LOG, HYPER_LOG_LOG); assertEquals(exactOperator.getName(), mangleOperatorName(OperatorType.CAST.name())); assertEquals(transform(exactOperator.getArgumentTypes(), Functions.toStringFunction()), ImmutableList.of(StandardTypes.HYPER_LOG_LOG)); assertEquals(exactOperator.getReturnType().getBase(), StandardTypes.HYPER_LOG_LOG); }
@Test public void testIdentityCast() { TypeRegistry typeManager = new TypeRegistry(); FunctionRegistry registry = new FunctionRegistry(typeManager, new BlockEncodingManager(typeManager), new FeaturesConfig()); Signature exactOperator = registry.getCoercion(HYPER_LOG_LOG, HYPER_LOG_LOG); assertEquals(exactOperator.getName(), mangleOperatorName(OperatorType.CAST.name())); assertEquals(transform(exactOperator.getArgumentTypes(), Functions.toStringFunction()), ImmutableList.of(StandardTypes.HYPER_LOG_LOG)); assertEquals(exactOperator.getReturnType().getBase(), StandardTypes.HYPER_LOG_LOG); }