pyflink.table.udf.udtf#
- udtf(f: Optional[Union[Callable, pyflink.table.udf.TableFunction, Type]] = None, input_types: Optional[Union[List[pyflink.table.types.DataType], pyflink.table.types.DataType, str, List[str]]] = None, result_types: Optional[Union[List[pyflink.table.types.DataType], pyflink.table.types.DataType, str, List[str]]] = None, deterministic: Optional[bool] = None, name: Optional[str] = None) Union[pyflink.table.udf.UserDefinedTableFunctionWrapper, Callable] [source]#
Helper method for creating a user-defined table function.
- Example:
>>> # The input_types is optional. >>> @udtf(result_types=[DataTypes.BIGINT(), DataTypes.BIGINT()]) ... def range_emit(s, e): ... for i in range(e): ... yield s, i >>> # Specify result_types via string >>> @udtf(result_types=['BIGINT', 'BIGINT']) ... def range_emit(s, e): ... for i in range(e): ... yield s, i >>> # Specify result_types via row string >>> @udtf(result_types='Row<a BIGINT, b BIGINT>') ... def range_emit(s, e): ... for i in range(e): ... yield s, i >>> class MultiEmit(TableFunction): ... def eval(self, i): ... return range(i) >>> multi_emit = udtf(MultiEmit(), DataTypes.BIGINT(), DataTypes.BIGINT())
- Parameters
f – user-defined table function.
input_types – optional, the input data types.
result_types – the result data types.
name – the function name.
deterministic – the determinism of the function’s results. True if and only if a call to this function is guaranteed to always return the same result given the same parameters. (default True)
- Returns
UserDefinedTableFunctionWrapper or function.
New in version 1.11.0.