pub trait VAggregate: Sized {
type State: Send + Sync + 'static;
type Shared: Send + Sync + 'static;
// Required methods
fn parameters() -> Result<Vec<LogicalType>>;
fn return_type() -> Result<LogicalType>;
fn init() -> Self::State;
fn update(
shared: &Self::Shared,
state: &mut Self::State,
input: &DataChunkHandle,
row: usize,
) -> UdfResult<()>;
fn combine(
shared: &Self::Shared,
source: &Self::State,
target: &mut Self::State,
);
fn finalize(
shared: &Self::Shared,
state: &Self::State,
output: &mut VectorMut<'_>,
row: usize,
) -> UdfResult<()>;
// Provided method
fn special_handling() -> bool { ... }
}Expand description
A DuckDB aggregate function: folds a set of input rows into one result value.
See the callback-containment contract in crate::udf.
Required Associated Types§
Sourcetype State: Send + Sync + 'static
type State: Send + Sync + 'static
The per-group accumulator. Allocated by DuckDB (uninitialised), set up by
init, and dropped by the generated destructor.
Registration-time shared state, available read-only to every callback via
DuckDB’s extra-info slot. Use () if the aggregate needs none.
Required Methods§
Sourcefn parameters() -> Result<Vec<LogicalType>>
fn parameters() -> Result<Vec<LogicalType>>
The input parameter types (one overload).
§Errors
Returns an error if a parameter’s logical type cannot be built.
Sourcefn return_type() -> Result<LogicalType>
fn return_type() -> Result<LogicalType>
Sourcefn update(
shared: &Self::Shared,
state: &mut Self::State,
input: &DataChunkHandle,
row: usize,
) -> UdfResult<()>
fn update( shared: &Self::Shared, state: &mut Self::State, input: &DataChunkHandle, row: usize, ) -> UdfResult<()>
Folds input’s row row into state. shared is the registration state.
§Errors
Returns an error to fail the query with that message.
Provided Methods§
Sourcefn special_handling() -> bool
fn special_handling() -> bool
Whether the aggregate should still be invoked for NULL inputs. false by
default (DuckDB skips rows whose argument is NULL).
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".