docs/api/udf.md
User-Defined Functions (UDFs) are a mechanism to run Python code on the data that lives in a DataFrame. A UDF can be used just like Expressions, allowing users to express computation that should be executed by Daft lazily.
To write a UDF, use the @daft.func or @daft.cls decorators to turn Python functions into Daft operations that work seamlessly with DataFrame expressions. Daft also supports custom aggregation functions, or UDAFs with @daft.udaf with a three-stage pipeline (aggregate, combine, finalize) that plugs into Daft's distributed aggregation engine.
Learn more about user-defined functions in the user guide: daft.func, daft.cls, daft.udaf.
::: daft.func
::: daft.udf._FuncDecorator
::: daft.cls
::: daft.method
::: daft.udf._MethodDecorator
::: daft.udf.udf_v2.Func
::: daft.udaf
!!! danger "To Be Removed in 0.8.0"
The `@daft.udf` decorator has been **deprecated** since Daft 0.7.0 and **will be removed in 0.8.0**.
Please use `@daft.func` and `@daft.cls` instead.
Using `@daft.udf` emits the following warning:
```
DeprecationWarning: The `@daft.udf` decorator is deprecated since Daft version >= 0.7.0
and will be removed in >= 0.8.0. Please use `@daft.func` and `@daft.cls` instead.
See the migration guide for more details:
https://docs.daft.ai/en/stable/custom-code/migration/
```
See the [migration guide](../custom-code/migration.md) for how to update your code.
::: daft.udf.udf options: heading_level: 4
::: daft.udf.UDF options: filters: ["!^_", "call"]