arrow_udf/lib.rs
1// Copyright 2024 RisingWave Labs
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7// http://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14
15#![doc = include_str!("../README.md")]
16
17use arrow_array::{RecordBatch, RecordBatchReader};
18pub use arrow_schema::ArrowError as Error;
19pub use arrow_udf_macros::function;
20
21/// A specialized `Result` type for Arrow UDF operations.
22pub type Result<T> = std::result::Result<T, Error>;
23
24#[cfg(feature = "duckdb")]
25pub mod duckdb;
26pub mod ffi;
27#[cfg(feature = "global_registry")]
28pub mod sig;
29pub mod types;
30
31/// A scalar function that operates on a record batch.
32pub type ScalarFunction = fn(input: &RecordBatch) -> Result<RecordBatch>;
33
34/// A table function that operates on a record batch and returns an iterator of record batches.
35pub type TableFunction = fn(input: &RecordBatch) -> Result<Box<dyn RecordBatchReader + Send>>;
36
37/// Internal APIs used by macros.
38#[doc(hidden)]
39pub mod codegen {
40 pub use arrow_arith;
41 pub use arrow_array;
42 pub use arrow_schema;
43 pub use chrono;
44 pub use genawaiter2;
45 #[cfg(feature = "global_registry")]
46 pub use linkme;
47 pub use rust_decimal;
48 pub use serde_json;
49}