Tutorials
User Defined Functions
Overview
xorq supports three types of user-defined functions (UDFs):
- Scalar UDFs: Process data row by row
- UDAFs: Aggregate functions that process groups of rows
- UDWFs: Window functions that operate over partitions and frames
All UDFs integrate with XORQ’s execution engine for optimal performance.
Scalar UDFs
The simplest type - processes one row at a time.
UDAFs (Aggregation Functions)
Process groups of rows to produce aggregate values.
UDWFs (Window Functions)
Process partitions of data with ordering and framing.
Expr Scalar UDF
Expr Scalar UDFs allow you to incorporate pre-computed values (like trained models) into your UDF execution. This is particularly useful for machine learning workflows. For the next example we are going to train an XGBoost model on data from the Lending Club
This pattern enables an end-to-end ML workflow where:
- The model is trained once using aggregated data
- The trained model is serialized and passed to prediction UDF
- Predictions are made in the query execution context without manual intervention