Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
174 changes: 173 additions & 1 deletion vortex-array/public-api.lock

Large diffs are not rendered by default.

5 changes: 5 additions & 0 deletions vortex-array/src/aggregate_fn/erased.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,11 @@ impl AggregateFnRef {
AggregateFnOptions { inner: &*self.0 }
}

/// Coerce the input type for this aggregate function.
pub fn coerce_args(&self, input_dtype: &DType) -> VortexResult<DType> {
self.0.coerce_args(input_dtype)
}

/// Compute the return [`DType`] per group given the input element type.
pub fn return_dtype(&self, input_dtype: &DType) -> VortexResult<DType> {
self.0.return_dtype(input_dtype)
Expand Down
5 changes: 5 additions & 0 deletions vortex-array/src/aggregate_fn/typed.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ pub(super) trait DynAggregateFn: 'static + Send + Sync + super::sealed::Sealed {
fn id(&self) -> AggregateFnId;
fn options_any(&self) -> &dyn Any;

fn coerce_args(&self, input_dtype: &DType) -> VortexResult<DType>;
fn return_dtype(&self, input_dtype: &DType) -> VortexResult<DType>;
fn state_dtype(&self, input_dtype: &DType) -> VortexResult<DType>;
fn accumulator(
Expand Down Expand Up @@ -84,6 +85,10 @@ impl<V: AggregateFnVTable> DynAggregateFn for AggregateFnInner<V> {
&self.options
}

fn coerce_args(&self, input_dtype: &DType) -> VortexResult<DType> {
V::coerce_args(&self.vtable, &self.options, input_dtype)
}

fn return_dtype(&self, input_dtype: &DType) -> VortexResult<DType> {
V::return_dtype(&self.vtable, &self.options, input_dtype)
}
Expand Down
9 changes: 9 additions & 0 deletions vortex-array/src/aggregate_fn/vtable.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,15 @@ pub trait AggregateFnVTable: 'static + Sized + Clone + Send + Sync {
vortex_bail!("Aggregate function {} is not deserializable", self.id());
}

/// Coerce the input type for this aggregate function.
///
/// This is optionally used by Vortex users when performing type coercion over a Vortex
/// expression. The default implementation returns the input type unchanged.
fn coerce_args(&self, options: &Self::Options, input_dtype: &DType) -> VortexResult<DType> {
let _ = options;
Ok(input_dtype.clone())
}

/// The return [`DType`] of the aggregate.
fn return_dtype(&self, options: &Self::Options, input_dtype: &DType) -> VortexResult<DType>;

Expand Down
Loading
Loading