Expand description
Bound expressions (DuckDB 1.5.0+).
Expression is an RAII wrapper around DuckDB’s duckdb_expression handle.
Extension authors obtain one from a scalar function’s bind callback via
ScalarBindInfo::argument, which
lets the bind phase inspect each argument’s static type and — when the
argument is a constant — fold it to a concrete Value.
This is the canonical way to implement scalar functions whose behaviour depends on a constant argument (for example a format string or a precision) that should be validated or pre-computed once at bind time rather than on every row.
§Example
use quack_rs::scalar::{RawScalarBindInfo, ScalarBindInfo};
unsafe extern "C" fn my_bind(info: RawScalarBindInfo) {
let bind = unsafe { ScalarBindInfo::new(info) };
if let Some(arg) = unsafe { bind.argument(0) } {
// Inspect the argument's static return type at bind time.
let _ty = arg.return_type();
if arg.is_foldable() {
// With a `ClientContext`, `arg.fold(&ctx)` pre-computes the constant.
}
}
}Structs§
- Expression
- RAII wrapper for a
duckdb_expression.