#udf #gandiva #shared #macro #defined #capability #basic

gandiva_rust_udf_shared

A basic shared library for gandiva rust udf

5 releases

new 0.1.5 Apr 9, 2024
0.1.4 Mar 18, 2024
0.1.2 Mar 7, 2024
0.1.1 Feb 21, 2024
0.1.0 Feb 1, 2024

#586 in Procedural macros

Download history 205/week @ 2024-02-19 53/week @ 2024-02-26 220/week @ 2024-03-04 40/week @ 2024-03-11 131/week @ 2024-03-18 95/week @ 2024-04-01

276 downloads per month
Used in 2 crates

Custom license

13KB
158 lines

Gandiva Rust UDF Macros

This crate provides a udf macro to simplify the creation of Gandiva UDFs in Rust.

Example

use gandiva_rust_udf_macro::udf;
use std::net::Ipv4Addr;

#[udf]
fn is_ipv4(addr: &str) -> bool {
    addr.parse::<Ipv4Addr>().is_ok()
}

The macro takes advantage of the Gandiva external C function capability [1], and the Rust function defined with the udf macro can be used as a Gandiva UDF.

Supported data types in UDF

Input parameters types

  • bool
  • i8
  • i16
  • i32
  • i64
  • f32
  • f64
  • &str

Return value types

  • bool
  • i8
  • i16
  • i32
  • i64
  • f32
  • f64
  • String
  • Result
    • If your function returns a Result, the error will be propagated to the caller.
    • The Result generics will have two types, the first one is the success value type, and the second one is the error type.
      • For example, Result<i64, String> means the function returns a Result with i64 as the success value type and String as the error type.

References

[1] Gandiva External Function Development Guide, https://arrow.apache.org/docs/cpp/gandiva/external_func.html

Dependencies

~1–2MB
~42K SLoC