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
24pub mod ffi;
25#[cfg(feature = "global_registry")]
26pub mod sig;
27pub mod types;
28
29/// A scalar function that operates on a record batch.
30pub type ScalarFunction = fn(input: &RecordBatch) -> Result<RecordBatch>;
31
32/// A table function that operates on a record batch and returns an iterator of record batches.
33pub type TableFunction = fn(input: &RecordBatch) -> Result<Box<dyn RecordBatchReader + Send>>;
34
35/// Internal APIs used by macros.
36#[doc(hidden)]
37pub mod codegen {
38    pub use arrow_arith;
39    pub use arrow_array;
40    pub use arrow_schema;
41    pub use chrono;
42    pub use genawaiter2;
43    #[cfg(feature = "global_registry")]
44    pub use linkme;
45    pub use rust_decimal;
46    pub use serde_json;
47}