SparkSession.
udf
Returns a UDFRegistration for UDF registration.
UDFRegistration
New in version 2.0.0.
Changed in version 3.4.0: Supports Spark Connect.
Examples
Register a Python UDF, and use it in SQL.
>>> strlen = spark.udf.register("strlen", lambda x: len(x)) >>> spark.sql("SELECT strlen('test')").show() +------------+ |strlen(test)| +------------+ | 4| +------------+