use of com.facebook.presto.grpc.udf.GrpcUdfRequest 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));
}
Aggregations