Search in sources :

Example 1 with Functions

use of com.google.common.base.Functions in project presto by prestodb.

the class TestFunctionRegistry method testDuplicateFunctions.

@Test(expectedExceptions = IllegalArgumentException.class, expectedExceptionsMessageRegExp = "\\QFunction already registered: custom_add(bigint,bigint):bigint\\E")
public void testDuplicateFunctions() {
    List<SqlFunction> functions = new FunctionListBuilder().scalars(CustomFunctions.class).getFunctions().stream().filter(input -> input.getSignature().getName().equals("custom_add")).collect(toImmutableList());
    TypeRegistry typeManager = new TypeRegistry();
    FunctionRegistry registry = new FunctionRegistry(typeManager, new BlockEncodingManager(typeManager), new FeaturesConfig());
    registry.addFunctions(functions);
    registry.addFunctions(functions);
}
Also used : TypeSignature(com.facebook.presto.spi.type.TypeSignature) QualifiedName(com.facebook.presto.sql.tree.QualifiedName) TypeManager(com.facebook.presto.spi.type.TypeManager) TIMESTAMP_WITH_TIME_ZONE(com.facebook.presto.spi.type.TimestampWithTimeZoneType.TIMESTAMP_WITH_TIME_ZONE) TypeRegistry(com.facebook.presto.type.TypeRegistry) Assert.assertEquals(org.testng.Assert.assertEquals) ScalarFunctionImplementation(com.facebook.presto.operator.scalar.ScalarFunctionImplementation) Test(org.testng.annotations.Test) FunctionRegistry.mangleOperatorName(com.facebook.presto.metadata.FunctionRegistry.mangleOperatorName) Lists.transform(com.google.common.collect.Lists.transform) BlockEncodingSerde(com.facebook.presto.spi.block.BlockEncodingSerde) SCALAR(com.facebook.presto.metadata.FunctionKind.SCALAR) ImmutableList(com.google.common.collect.ImmutableList) FunctionRegistry.getMagicLiteralFunctionSignature(com.facebook.presto.metadata.FunctionRegistry.getMagicLiteralFunctionSignature) TypeSignatureProvider.fromTypeSignatures(com.facebook.presto.sql.analyzer.TypeSignatureProvider.fromTypeSignatures) Signature.typeVariable(com.facebook.presto.metadata.Signature.typeVariable) StandardTypes(com.facebook.presto.spi.type.StandardTypes) ImmutableCollectors.toImmutableList(com.facebook.presto.util.ImmutableCollectors.toImmutableList) Assert.assertFalse(org.testng.Assert.assertFalse) Functions(com.google.common.base.Functions) ImmutableSet(com.google.common.collect.ImmutableSet) FunctionRegistry.unmangleOperator(com.facebook.presto.metadata.FunctionRegistry.unmangleOperator) HYPER_LOG_LOG(com.facebook.presto.spi.type.HyperLogLogType.HYPER_LOG_LOG) MethodHandles(java.lang.invoke.MethodHandles) Assert.fail(org.testng.Assert.fail) String.format(java.lang.String.format) CustomFunctions(com.facebook.presto.operator.scalar.CustomFunctions) TypeUtils.resolveTypes(com.facebook.presto.type.TypeUtils.resolveTypes) FeaturesConfig(com.facebook.presto.sql.analyzer.FeaturesConfig) List(java.util.List) Collectors.toList(java.util.stream.Collectors.toList) OperatorType(com.facebook.presto.spi.function.OperatorType) Assert.assertTrue(org.testng.Assert.assertTrue) TypeSignature.parseTypeSignature(com.facebook.presto.spi.type.TypeSignature.parseTypeSignature) ScalarFunction(com.facebook.presto.spi.function.ScalarFunction) Collections(java.util.Collections) SqlType(com.facebook.presto.spi.function.SqlType) BlockEncodingManager(com.facebook.presto.block.BlockEncodingManager) BlockEncodingManager(com.facebook.presto.block.BlockEncodingManager) FeaturesConfig(com.facebook.presto.sql.analyzer.FeaturesConfig) TypeRegistry(com.facebook.presto.type.TypeRegistry) Test(org.testng.annotations.Test)

Aggregations

BlockEncodingManager (com.facebook.presto.block.BlockEncodingManager)1 SCALAR (com.facebook.presto.metadata.FunctionKind.SCALAR)1 FunctionRegistry.getMagicLiteralFunctionSignature (com.facebook.presto.metadata.FunctionRegistry.getMagicLiteralFunctionSignature)1 FunctionRegistry.mangleOperatorName (com.facebook.presto.metadata.FunctionRegistry.mangleOperatorName)1 FunctionRegistry.unmangleOperator (com.facebook.presto.metadata.FunctionRegistry.unmangleOperator)1 Signature.typeVariable (com.facebook.presto.metadata.Signature.typeVariable)1 CustomFunctions (com.facebook.presto.operator.scalar.CustomFunctions)1 ScalarFunctionImplementation (com.facebook.presto.operator.scalar.ScalarFunctionImplementation)1 BlockEncodingSerde (com.facebook.presto.spi.block.BlockEncodingSerde)1 OperatorType (com.facebook.presto.spi.function.OperatorType)1 ScalarFunction (com.facebook.presto.spi.function.ScalarFunction)1 SqlType (com.facebook.presto.spi.function.SqlType)1 HYPER_LOG_LOG (com.facebook.presto.spi.type.HyperLogLogType.HYPER_LOG_LOG)1 StandardTypes (com.facebook.presto.spi.type.StandardTypes)1 TIMESTAMP_WITH_TIME_ZONE (com.facebook.presto.spi.type.TimestampWithTimeZoneType.TIMESTAMP_WITH_TIME_ZONE)1 TypeManager (com.facebook.presto.spi.type.TypeManager)1 TypeSignature (com.facebook.presto.spi.type.TypeSignature)1 TypeSignature.parseTypeSignature (com.facebook.presto.spi.type.TypeSignature.parseTypeSignature)1 FeaturesConfig (com.facebook.presto.sql.analyzer.FeaturesConfig)1 TypeSignatureProvider.fromTypeSignatures (com.facebook.presto.sql.analyzer.TypeSignatureProvider.fromTypeSignatures)1