use of com.facebook.presto.spi.function.FunctionImplementationType.THRIFT in project presto by prestodb.
the class SimpleAddressThriftSqlFunctionExecutionModule method setup.
@Override
protected void setup(Binder binder) {
ImmutableMap.Builder<Language, SimpleAddressSelectorConfig> thriftConfigBuilder = ImmutableMap.builder();
ImmutableMap.Builder<Language, ThriftSqlFunctionExecutionConfig> thriftExecutionConfigs = ImmutableMap.builder();
for (Map.Entry<String, FunctionImplementationType> entry : supportedLanguages.entrySet()) {
String languageName = entry.getKey();
Language language = new Language(languageName);
FunctionImplementationType implementationType = entry.getValue();
if (implementationType.equals(THRIFT)) {
thriftConfigBuilder.put(language, buildConfigObject(SimpleAddressSelectorConfig.class, languageName));
thriftExecutionConfigs.put(language, buildConfigObject(ThriftSqlFunctionExecutionConfig.class, languageName));
}
}
Map<Language, SimpleAddressSelectorConfig> thriftConfigs = thriftConfigBuilder.build();
if (thriftConfigs.isEmpty()) {
binder.bind(SqlFunctionExecutor.class).to(NoopSqlFunctionExecutor.class).in(Scopes.SINGLETON);
return;
}
binder.bind(SqlFunctionExecutor.class).to(ThriftSqlFunctionExecutor.class).in(Scopes.SINGLETON);
driftClientBinder(binder).bindDriftClient(ThriftUdfService.class).withAddressSelector(contextualSimpleAddressSelector(thriftConfigs.entrySet().stream().collect(toImmutableMap(entry -> entry.getKey().getLanguage(), Map.Entry::getValue))));
binder.bind(new TypeLiteral<Map<Language, ThriftSqlFunctionExecutionConfig>>() {
}).toInstance(thriftExecutionConfigs.build());
}
use of com.facebook.presto.spi.function.FunctionImplementationType.THRIFT 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());
}
Aggregations