1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
// SPDX-License-Identifier: MIT
// Copyright 2026 Tom F. <https://github.com/tomtom215/>
// My way of giving something small back to the open source community
// and encouraging more Rust development!
//! Builder for registering `DuckDB` scalar functions.
//!
//! Scalar functions process one data chunk at a time and return a single value
//! per row. They are the most common type of function in `DuckDB` extensions.
//!
//! Both [`ScalarFunctionBuilder`] and [`ScalarFunctionSetBuilder`] support:
//! - Simple parameter types via `param(TypeId)`
//! - Complex parameterized types via `param_logical(LogicalType)` (e.g.,
//! `LIST(BIGINT)`, `MAP(VARCHAR, INTEGER)`, `STRUCT(...)`)
//! - Complex return types via `returns_logical(LogicalType)`
//! - Per-function NULL handling via `null_handling(NullHandling)`
//!
//! # Example
//!
//! ```rust,no_run
//! use quack_rs::scalar::ScalarFunctionBuilder;
//! use quack_rs::types::TypeId;
//! use libduckdb_sys::{duckdb_connection, duckdb_function_info, duckdb_data_chunk,
//! duckdb_vector};
//!
//! unsafe extern "C" fn my_func(
//! _info: duckdb_function_info,
//! _input: duckdb_data_chunk,
//! _output: duckdb_vector,
//! ) {}
//!
//! // fn register(con: duckdb_connection) -> Result<(), quack_rs::error::ExtensionError> {
//! // unsafe {
//! // ScalarFunctionBuilder::new("double_it")
//! // .param(TypeId::BigInt)
//! // .returns(TypeId::BigInt)
//! // .function(my_func)
//! // .register(con)
//! // }
//! // }
//! ```
pub use ;
pub use ScalarFunctionInfo;
pub use ;