Remote UDF Service The Remote UDF Service can be accessed through RPC to implement the execution of user-defined functions. Compared with Native UDF implementations, Remote UDF Service has the following advantages and limitations:
The advantage
Restrictions on use
This section describes how to develop a Remote RPC Service. Samples for the Java version are provided under samples/doris-demo/udf-demo/ for your reference.
Copy gensrc/proto/function_service.proto and gensrc/proto/types.proto to Rpc service
Use protoc generate code, and specific parameters are viewed using protoc -h
The following three methods need to be implemented
Currently, UDAF and UDTF are not supported
CREATE FUNCTION name ([,...]) [RETURNS] rettype PROPERTIES (["key"="value"][,...])
Instructions:
symbolRepresents the name of the method passed by the RPC call, which must be set。object_fileRepresents the RPC service address. Currently, a single address and a cluster address in BRPC-compatible format are supported. Refer to the cluster connection modeFormat specification。typeIndicates the UDF call type, which is Native by default. Rpc is transmitted when Rpc UDF is used。dbName.funcName. When dbName is not explicitly specified, the db of the current session is useddbName。Sample:
CREATE FUNCTION rpc_add(INT, INT) RETURNS INT PROPERTIES ( "SYMBOL"="add_int", "OBJECT_FILE"="127.0.0.1:9090", "TYPE"="RPC" );
Users must have the SELECT permission of the corresponding database to use UDF/UDAF.
The use of UDF is consistent with ordinary function methods. The only difference is that the scope of built-in functions is global, and the scope of UDF is internal to DB. When the link session is inside the data, directly using the UDF name will find the corresponding UDF inside the current DB. Otherwise, the user needs to display the specified UDF database name, such as dbName.funcName.
When you no longer need UDF functions, you can delete a UDF function by the following command, you can refer to DROP FUNCTION.
Examples of rpc server implementations and cpp/java/python languages are provided in the samples/doris-demo/ directory. See the README.md in each directory for details on how to use it.