Search in sources :

Example 6 with SqlInvokedFunctionNamespaceManagerConfig

use of com.facebook.presto.functionNamespace.SqlInvokedFunctionNamespaceManagerConfig in project presto by prestodb.

the class TestPlanRemoteProjections method testRemoteFunctionDisabled.

@Test(expectedExceptions = PrestoException.class, expectedExceptionsMessageRegExp = ".*Remote functions are not enabled")
public void testRemoteFunctionDisabled() {
    RuleTester tester = new RuleTester(ImmutableList.of());
    FunctionAndTypeManager functionAndTypeManager = tester.getMetadata().getFunctionAndTypeManager();
    functionAndTypeManager.addFunctionNamespace("unittest", new InMemoryFunctionNamespaceManager("unittest", new SqlFunctionExecutors(ImmutableMap.of(SQL, FunctionImplementationType.SQL, JAVA, THRIFT), new NoopSqlFunctionExecutor()), new SqlInvokedFunctionNamespaceManagerConfig().setSupportedFunctionLanguages("sql,java")));
    functionAndTypeManager.createFunction(FUNCTION_REMOTE_FOO_1, true);
    tester.assertThat(new PlanRemotePojections(functionAndTypeManager)).on(p -> {
        p.variable("x", INTEGER);
        return p.project(Assignments.builder().put(p.variable("a"), p.rowExpression("unittest.memory.remote_foo(x)")).build(), p.values(p.variable("x", INTEGER)));
    }).matches(anyTree());
}
Also used : FunctionAndTypeManager(com.facebook.presto.metadata.FunctionAndTypeManager) Parameter(com.facebook.presto.spi.function.Parameter) StandardTypes(com.facebook.presto.common.type.StandardTypes) SqlInvokedFunctionNamespaceManagerConfig(com.facebook.presto.functionNamespace.SqlInvokedFunctionNamespaceManagerConfig) SQL(com.facebook.presto.spi.function.RoutineCharacteristics.Language.SQL) PlanMatchPattern.anyTree(com.facebook.presto.sql.planner.assertions.PlanMatchPattern.anyTree) Assignments(com.facebook.presto.spi.plan.Assignments) Assert.assertEquals(org.testng.Assert.assertEquals) Test(org.testng.annotations.Test) SqlInvokedFunction(com.facebook.presto.spi.function.SqlInvokedFunction) PrestoException(com.facebook.presto.spi.PrestoException) ProjectionContext(com.facebook.presto.sql.planner.iterative.rule.PlanRemotePojections.ProjectionContext) PlanMatchPattern(com.facebook.presto.sql.planner.assertions.PlanMatchPattern) TEST_SESSION(com.facebook.presto.SessionTestUtils.TEST_SESSION) ImmutableList(com.google.common.collect.ImmutableList) QualifiedObjectName(com.facebook.presto.common.QualifiedObjectName) PlanBuilder(com.facebook.presto.sql.planner.iterative.rule.test.PlanBuilder) BOOLEAN(com.facebook.presto.common.type.BooleanType.BOOLEAN) THRIFT(com.facebook.presto.spi.function.FunctionImplementationType.THRIFT) RoutineCharacteristics(com.facebook.presto.spi.function.RoutineCharacteristics) PlanNodeIdAllocator(com.facebook.presto.spi.plan.PlanNodeIdAllocator) PlanMatchPattern.project(com.facebook.presto.sql.planner.assertions.PlanMatchPattern.project) ImmutableMap(com.google.common.collect.ImmutableMap) FunctionImplementationType(com.facebook.presto.spi.function.FunctionImplementationType) BeforeClass(org.testng.annotations.BeforeClass) DETERMINISTIC(com.facebook.presto.spi.function.RoutineCharacteristics.Determinism.DETERMINISTIC) InMemoryFunctionNamespaceManager(com.facebook.presto.functionNamespace.testing.InMemoryFunctionNamespaceManager) DOUBLE(com.facebook.presto.common.type.StandardTypes.DOUBLE) SqlFunctionExecutors(com.facebook.presto.functionNamespace.execution.SqlFunctionExecutors) List(java.util.List) TypeSignature.parseTypeSignature(com.facebook.presto.common.type.TypeSignature.parseTypeSignature) RETURNS_NULL_ON_NULL_INPUT(com.facebook.presto.spi.function.RoutineCharacteristics.NullCallClause.RETURNS_NULL_ON_NULL_INPUT) ExpressionMatcher(com.facebook.presto.sql.planner.assertions.ExpressionMatcher) PlanVariableAllocator(com.facebook.presto.sql.planner.PlanVariableAllocator) INTEGER(com.facebook.presto.common.type.IntegerType.INTEGER) FunctionVersion.notVersioned(com.facebook.presto.spi.function.FunctionVersion.notVersioned) CatalogSchemaName(com.facebook.presto.common.CatalogSchemaName) PlanMatchPattern.values(com.facebook.presto.sql.planner.assertions.PlanMatchPattern.values) NoopSqlFunctionExecutor(com.facebook.presto.functionNamespace.execution.NoopSqlFunctionExecutor) RuleTester(com.facebook.presto.sql.planner.iterative.rule.test.RuleTester) Metadata(com.facebook.presto.metadata.Metadata) FunctionAndTypeManager(com.facebook.presto.metadata.FunctionAndTypeManager) NoopSqlFunctionExecutor(com.facebook.presto.functionNamespace.execution.NoopSqlFunctionExecutor) RuleTester(com.facebook.presto.sql.planner.iterative.rule.test.RuleTester) SqlFunctionExecutors(com.facebook.presto.functionNamespace.execution.SqlFunctionExecutors) InMemoryFunctionNamespaceManager(com.facebook.presto.functionNamespace.testing.InMemoryFunctionNamespaceManager) SqlInvokedFunctionNamespaceManagerConfig(com.facebook.presto.functionNamespace.SqlInvokedFunctionNamespaceManagerConfig) Test(org.testng.annotations.Test)

Aggregations

SqlInvokedFunctionNamespaceManagerConfig (com.facebook.presto.functionNamespace.SqlInvokedFunctionNamespaceManagerConfig)6 NoopSqlFunctionExecutor (com.facebook.presto.functionNamespace.execution.NoopSqlFunctionExecutor)5 SqlFunctionExecutors (com.facebook.presto.functionNamespace.execution.SqlFunctionExecutors)5 InMemoryFunctionNamespaceManager (com.facebook.presto.functionNamespace.testing.InMemoryFunctionNamespaceManager)5 FunctionAndTypeManager (com.facebook.presto.metadata.FunctionAndTypeManager)4 BeforeClass (org.testng.annotations.BeforeClass)4 RuleTester (com.facebook.presto.sql.planner.iterative.rule.test.RuleTester)3 FunctionImplementationType (com.facebook.presto.spi.function.FunctionImplementationType)2 TEST_SESSION (com.facebook.presto.SessionTestUtils.TEST_SESSION)1 CatalogSchemaName (com.facebook.presto.common.CatalogSchemaName)1 QualifiedObjectName (com.facebook.presto.common.QualifiedObjectName)1 ArrayType (com.facebook.presto.common.type.ArrayType)1 BOOLEAN (com.facebook.presto.common.type.BooleanType.BOOLEAN)1 INTEGER (com.facebook.presto.common.type.IntegerType.INTEGER)1 RowType (com.facebook.presto.common.type.RowType)1 StandardTypes (com.facebook.presto.common.type.StandardTypes)1 DOUBLE (com.facebook.presto.common.type.StandardTypes.DOUBLE)1 TypeSignature.parseTypeSignature (com.facebook.presto.common.type.TypeSignature.parseTypeSignature)1 Catalog (com.facebook.presto.metadata.Catalog)1 CatalogManager (com.facebook.presto.metadata.CatalogManager)1