pyflink.table.table_environment.StreamTableEnvironment.create_temporary_system_function#
- StreamTableEnvironment.create_temporary_system_function(name: str, function: Union[pyflink.table.udf.UserDefinedFunctionWrapper, pyflink.table.udf.AggregateFunction])#
Registers a python user defined function class as a temporary system function.
Compared to .. seealso::
create_temporary_function()
, system functions are identified by a global name that is independent of the current catalog and current database. Thus, this method allows to extend the set of built-in system functions like TRIM, ABS, etc.Temporary functions can shadow permanent ones. If a permanent function under a given name exists, it will be inaccessible in the current session. To make the permanent function available again one can drop the corresponding temporary system function.
Example:
>>> table_env.create_temporary_system_function( ... "add_one", udf(lambda i: i + 1, result_type=DataTypes.BIGINT())) >>> @udf(result_type=DataTypes.BIGINT()) ... def add(i, j): ... return i + j >>> table_env.create_temporary_system_function("add", add) >>> class SubtractOne(ScalarFunction): ... def eval(self, i): ... return i - 1 >>> table_env.create_temporary_system_function( ... "subtract_one", udf(SubtractOne(), result_type=DataTypes.BIGINT()))
- Parameters
name – The name under which the function will be registered globally.
function – The function class containing the implementation. The function must have a public no-argument constructor and can be founded in current Java classloader.
New in version 1.12.0.