UDF Overview
Arroyo SQL can be extended with user-defined functions, written in Rust or Python. The parameters and return type of the UDF are determined by the definition of the function and all types must be valid SQL data types.
For String and Binary types (TEXT BYTEA in SQL), UDFs use the reference type
(&str and &[u8]) for arguments and the owned types (String and Vec<u8>)
for return values.
Arroyo UDFs are annotated with the #[udf] in the arroyo_udf_plugin crate if they
are written in rust and the @udf decorators if you use Python. UDFs can be defined
as part of the SQL API call, or via the Web UI.
Here’s an example of a simple UDF that squares an integer:
from arroyo_udf import udf
@udfdef my_square(x: int) -> int: return x * xuse arroyo_udf_plugin::udf;
#[udf]fn my_square(x: u64) -> u64 { x * x}Once registered, this UDF can be used in SQL queries:
CREATE TABLE impulse