User Defined Functions#
The udf() decorator creates user-defined scalar functions for use with the
DataFrame API. It supports plain functions, async functions, ScalarFunction
subclasses, and callable classes. The udtf() decorator creates
user-defined table functions that emit zero or more rows per input, for use
with flat_map() and join_lateral().
Example:
>>> from pyflink.dataframe import udf, udtf, DataType
>>> @udf(return_dtype=DataType.string())
... def to_upper(s: str) -> str:
... return s.upper()
...
>>> @udtf(return_dtype=DataType.string())
... def split_words(text: str):
... for word in text.split():
... yield word
Functions#
|
Create a user-defined function for DataFrame operations. |
|
Create a user-defined table function for DataFrame operations. |