Skip to main content

AggregateFunctionInfo

Struct AggregateFunctionInfo 

Source
pub struct AggregateFunctionInfo { /* private fields */ }
Expand description

Ergonomic wrapper around the duckdb_function_info handle provided to aggregate function callbacks (update, combine, finalize, etc.).

Provides access to extra info and error reporting.

Implementations§

Source§

impl AggregateFunctionInfo

Source

pub const unsafe fn new(info: duckdb_function_info) -> Self

Wraps a raw duckdb_function_info provided by DuckDB inside an aggregate function callback.

§Safety

info must be a valid duckdb_function_info passed by DuckDB to an aggregate function callback.

Source

pub unsafe fn get_extra_info(&self) -> *mut c_void

Retrieves the extra-info pointer previously set via AggregateFunctionBuilder::extra_info.

Returns a raw *mut c_void. Cast it back to your concrete type.

§Safety

The returned pointer is only valid as long as the aggregate function is registered and DuckDB has not yet called the destructor.

Source

pub unsafe fn extra_info_ref<T: 'static>(&self) -> Option<&T>

Borrows the extra info set with extra_info_typed (on AggregateFunctionBuilder or AggregateOverloadBuilder) as a T; None when none was set or it holds another type.

§Safety

This function’s extra info, if any, was set through extra_info_typed and not through the raw extra_info: the type tag read here is the one extra_info_typed writes, and a raw pointer carries none.

Source

pub fn set_error(&self, message: &str)

Reports an error from an aggregate function callback, causing DuckDB to abort the current query.

An interior NUL byte in message is replaced with ? (see message_to_c_string), and an empty message by EMPTY_ERROR_PLACEHOLDER, since DuckDB would otherwise report only an error-type prefix.

Called from finalize, the query fails but DuckDB does not destroy every aggregate state it created, so whatever those states own (an FfiState box, for one) leaks. That holds for a grouped aggregate on every release up to 2.0.0, and for an ungrouped one before 2.0.0, which plans a C API aggregate as a hash aggregate; 2.0.0 runs an ungrouped aggregate in PhysicalUngroupedAggregate, which destroys its states. See Known Limitations in the book.

Source

pub const fn as_raw(&self) -> duckdb_function_info

Returns the raw duckdb_function_info handle.

Trait Implementations§

Source§

impl Debug for AggregateFunctionInfo

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.