Gandiva Rust UDF
This project is a collection of UDFs written in Rust for Apache Arrow Gandiva.
How to write a new UDF
- Create a new cargo workspace, like
my_func - Two dependencies should be added for this new workspace:
- gandiva_rust_udf_macro
- gandiva_rust_udf_shared
- If your function accepts string parameter or returns string value, you should add
libcas dependency - Add a new function in
my_func/src/lib.rs- import
use gandiva_rust_udf_macro::udf - use
#[udf]macro to annotate this function - Unit test your function
- import
- Add
my_funcas dependency inudf_core/Cargo.toml - Register
my_funcinudf_core/src/lib.rs - Compile
udf_coreas shared librarycargo build --release --lib --workspace
- Deploy
libudf_coreshared library to where your Gandiva application can load it
How to create a different project like this
- udf_core
[lib]
crate-type = ["cdylib"]
- each function MUST depends on
gandiva_rust_udf_sharedcrate