Search in sources :

Example 1 with ThriftUdfService

use of com.facebook.presto.thrift.api.udf.ThriftUdfService in project presto by prestodb.

the class ThriftSqlFunctionExecutor method executeFunction.

@Override
public CompletableFuture<SqlFunctionResult> executeFunction(String source, RemoteScalarFunctionImplementation functionImplementation, Page input, List<Integer> channels, List<Type> argumentTypes, Type returnType) {
    ThriftUdfPage page = buildThriftPage(functionImplementation, input, channels, argumentTypes);
    SqlFunctionHandle functionHandle = functionImplementation.getFunctionHandle();
    SqlFunctionId functionId = functionHandle.getFunctionId();
    ThriftFunctionHandle thriftFunctionHandle = new ThriftFunctionHandle(functionId.getFunctionName().toString(), functionId.getArgumentTypes().stream().map(TypeSignature::toString).collect(toImmutableList()), returnType.toString(), functionHandle.getVersion());
    ThriftUdfService thriftUdfService = thriftUdfClient.get(Optional.of(functionImplementation.getLanguage().getLanguage()));
    return invokeUdfWithRetry(thriftUdfService, new ThriftUdfRequest(source, thriftFunctionHandle, page)).thenApply(thriftResult -> toSqlFunctionResult(thriftResult, returnType));
}
Also used : TypeSignature(com.facebook.presto.common.type.TypeSignature) SqlFunctionId(com.facebook.presto.spi.function.SqlFunctionId) ThriftFunctionHandle(com.facebook.presto.thrift.api.udf.ThriftFunctionHandle) ThriftUdfRequest(com.facebook.presto.thrift.api.udf.ThriftUdfRequest) SqlFunctionHandle(com.facebook.presto.spi.function.SqlFunctionHandle) ThriftUdfPage(com.facebook.presto.thrift.api.udf.ThriftUdfPage) ThriftUdfService(com.facebook.presto.thrift.api.udf.ThriftUdfService)

Aggregations

TypeSignature (com.facebook.presto.common.type.TypeSignature)1 SqlFunctionHandle (com.facebook.presto.spi.function.SqlFunctionHandle)1 SqlFunctionId (com.facebook.presto.spi.function.SqlFunctionId)1 ThriftFunctionHandle (com.facebook.presto.thrift.api.udf.ThriftFunctionHandle)1 ThriftUdfPage (com.facebook.presto.thrift.api.udf.ThriftUdfPage)1 ThriftUdfRequest (com.facebook.presto.thrift.api.udf.ThriftUdfRequest)1 ThriftUdfService (com.facebook.presto.thrift.api.udf.ThriftUdfService)1