當前位置: 首頁>>編程示例 >>用法及示例精選 >>正文


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。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。