pyflink.table.udf.udtf#
- udtf(f: Callable | TableFunction | Type, input_types: List[DataType] | DataType | str | List[str] | None = None, result_types: List[DataType] | DataType | str | List[str] | None = None, deterministic: bool | None = None, name: str | None = None) UserDefinedTableFunctionWrapper[source]#
- udtf(f: None = None, input_types: List[DataType] | DataType | str | List[str] | None = None, result_types: List[DataType] | DataType | str | List[str] | None = None, deterministic: bool | None = None, name: str | None = None) Callable[[Callable | TableFunction | Type], UserDefinedTableFunctionWrapper]
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.
Added in version 1.11.0.