Search in sources :

Example 1 with GrpcFunctionHandle

use of com.facebook.presto.grpc.udf.GrpcFunctionHandle in project presto by prestodb.

the class GrpcSqlFunctionExecutor method executeFunction.

@Override
public CompletableFuture<SqlFunctionResult> executeFunction(String source, RemoteScalarFunctionImplementation functionImplementation, Page input, List<Integer> channels, List<Type> argumentTypes, Type returnType) {
    GrpcUdfPage grpcUdfPage = buildGrpcUdfPage(input, channels, grpcUdfConfigs.get(functionImplementation.getLanguage()).getGrpcUdfPageFormat());
    SqlFunctionHandle functionHandle = functionImplementation.getFunctionHandle();
    SqlFunctionId functionId = functionHandle.getFunctionId();
    GrpcFunctionHandle grpcFunctionHandle = GrpcFunctionHandle.newBuilder().setFunctionName(functionId.getFunctionName().toString()).addAllArgumentTypes(functionId.getArgumentTypes().stream().map(TypeSignature::toString).collect(toImmutableList())).setReturnType(returnType.toString()).setVersion(functionHandle.getVersion()).build();
    GrpcUdfRequest grpcUdfRequest = GrpcUdfRequest.newBuilder().setSource(source).setGrpcFunctionHandle(grpcFunctionHandle).setInputs(grpcUdfPage).build();
    return invokeUdfWithRetry(futureStubs.get(functionImplementation.getLanguage()), grpcUdfRequest).thenApply(grpcResult -> toSqlFunctionResult(grpcResult));
}
Also used : GrpcUdfRequest(com.facebook.presto.grpc.udf.GrpcUdfRequest) SqlFunctionId(com.facebook.presto.spi.function.SqlFunctionId) GrpcUtils.toGrpcUdfPage(com.facebook.presto.grpc.api.udf.GrpcUtils.toGrpcUdfPage) GrpcUdfPage(com.facebook.presto.grpc.udf.GrpcUdfPage) SqlFunctionHandle(com.facebook.presto.spi.function.SqlFunctionHandle) GrpcFunctionHandle(com.facebook.presto.grpc.udf.GrpcFunctionHandle)

Aggregations

GrpcUtils.toGrpcUdfPage (com.facebook.presto.grpc.api.udf.GrpcUtils.toGrpcUdfPage)1 GrpcFunctionHandle (com.facebook.presto.grpc.udf.GrpcFunctionHandle)1 GrpcUdfPage (com.facebook.presto.grpc.udf.GrpcUdfPage)1 GrpcUdfRequest (com.facebook.presto.grpc.udf.GrpcUdfRequest)1 SqlFunctionHandle (com.facebook.presto.spi.function.SqlFunctionHandle)1 SqlFunctionId (com.facebook.presto.spi.function.SqlFunctionId)1