vortex-array 0.91.0

Vortex in memory columnar data format
Documentation
// SPDX-License-Identifier: Apache-2.0
// SPDX-FileCopyrightText: Copyright the Vortex contributors

use vortex_error::VortexResult;

use super::MinMaxPartial;
use super::MinMaxResult;
use super::min_max;
use crate::ExecutionCtx;
use crate::aggregate_fn::AggregateArgs;
use crate::aggregate_fn::NumericalAggregateOpts;
use crate::arrays::ExtensionArray;
use crate::arrays::extension::ExtensionArrayExt;
use crate::dtype::Nullability;
use crate::scalar::Scalar;

pub(super) fn accumulate_extension(
    args: AggregateArgs<'_, NumericalAggregateOpts>,
    partial: &mut MinMaxPartial,
    array: &ExtensionArray,
    ctx: &mut ExecutionCtx,
) -> VortexResult<()> {
    let non_nullable_ext_dtype = array.ext_dtype().with_nullability(Nullability::NonNullable);

    // A NaN in float storage comes back as NaN extrema, which `merge` skips or poisons with.
    let Some(MinMaxResult { min, max }) = min_max(array.storage_array(), ctx, *args.options)?
    else {
        return Ok(());
    };

    let local = MinMaxResult {
        min: Scalar::try_extension_ref(non_nullable_ext_dtype.clone(), min)?,
        max: Scalar::try_extension_ref(non_nullable_ext_dtype, max)?,
    };

    partial.merge(args, Some(local))
}