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
Built-in Python Dependencies#
Alibaba Cloud Realtime Compute for Apache Flink supports Python 3.9, 3.10, and 3.11. The following user-facing dependencies are preinstalled and can be used directly in UDFs. To use other dependencies, configure a custom Python environment.
attrs==26.1.0
audioread==3.1.0
av==14.2.0
avro-python3==1.10.2
brotlipy==0.7.0
certifi==2026.5.20
cffi==1.17.1
charset-normalizer==3.4.7
cloudpickle==2.2.1
contourpy==1.3.0
crcmod==1.7
cryptography==38.0.1
cycler==0.12.1
decorator==5.3.1
dill==0.3.1.1
dnspython==2.7.0
docopt==0.6.2
easyocr==1.7.2
exceptiongroup==1.3.1
fastavro==1.12.2
fasteners==0.20
filelock==3.19.1
fonttools==4.60.2
ftfy==6.3.1
grpcio==1.56.2
grpcio-tools==1.56.2
hdfs==2.7.3
httplib2==0.22.0
huggingface-hub==0.36.2
idna==3.18
ImageHash==4.3.2
importlib-metadata==8.7.1
importlib-resources==5.4.0
joblib==1.5.3
jsonschema==4.25.1
jsonschema-specifications==2025.9.1
kiwisolver==1.4.7
lazy-loader==0.5
librosa==0.11.0
llvmlite==0.43.0
matplotlib==3.9.4
mpmath==1.3.0
msgpack==1.1.2
numba==0.60.0
numpy==1.24.4
objsize==0.6.1
onnxruntime==1.16.3
open-clip-torch==2.32.0
opencv-python-headless==4.10.0.84
orjson==3.9.15
packaging==26.2
pandas==2.2.3
pillow==11.3.0
platformdirs==4.4.0
pooch==1.9.0
proto-plus==1.27.1
protobuf==4.25.9
pyarrow==11.0.0
pyarrow-hotfix==0.6
pycparser==2.23
pydot==1.4.2
PyMatting==1.1.15
pymongo==4.17.0
pyOpenSSL==22.0.0
pyparsing==3.3.2
PySocks==1.7.1
python-bidi==0.6.10
python-dateutil==2.9.0.post0
pytz==2026.2
PyWavelets==1.6.0
PyYAML==6.0.3
referencing==0.36.2
regex==2026.1.15
rembg==2.0.61
requests==2.32.5
rpds-py==0.27.1
ruamel.yaml==0.19.1
ruamel.yaml.clib==0.2.6
safetensors==0.7.0
scikit-image==0.24.0
scikit-learn==1.6.1
scipy==1.13.1
shapely==2.0.7
six==1.17.0
soundfile==0.13.1
soxr==0.5.0.post1
sympy==1.13.1
threadpoolctl==3.6.0
tifffile==2024.8.30
timm==1.0.27
tokenizers==0.22.2
tomli==2.4.1
toolz==0.12.0
torch==2.5.1
torchvision==0.20.1
tqdm==4.64.1
transformers==4.57.6
typing-extensions==4.15.0
tzdata==2026.2
ultralytics==8.4.66
urllib3==2.6.3
wcwidth==0.8.1
webrtcvad-wheels==2.0.14
zipp==3.23.1
zstandard==0.25.0
Functions#
|
Create a user-defined function for DataFrame operations. |
|
Create a user-defined table function for DataFrame operations. |