当前位置: 首页>>编程示例 >>用法及示例精选 >>正文


Python pyflink TableEnvironment.register_function用法及代码示例

本文简要介绍 python 语言中 pyflink.table.TableEnvironment.register_function 的用法。

用法:

register_function(name: str, function: pyflink.table.udf.UserDefinedFunctionWrapper)

以唯一名称注册 python 用户定义函数。替换此名称下已经存在的用户定义函数。

例子:

>>> table_env.register_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.register_function("add", add)

>>> class SubtractOne(ScalarFunction):
...     def eval(self, i):
...         return i - 1
>>> table_env.register_function(
...     "subtract_one", udf(SubtractOne(), result_type=DataTypes.BIGINT()))

参数:

  • name- 注册函数的名称。

  • function- 要注册的 python 用户定义函数。

版本 1.10.0 中的新函数。

注意:

1.12 中已弃用。请改用create_temporary_system_function()

相关用法


注:本文由纯净天空筛选整理自apache.org大神的英文原创作品 pyflink.table.TableEnvironment.register_function。非经特殊声明,原始代码版权归原作者所有,本译文未经允许或授权,请勿转载或复制。