Skip to content

Expose optional num_centroids argument in approx_percentile_cont's fluent API #11877

Description

@Michael-J-Ward

Is your feature request related to a problem or challenge?

approx_percentile_cont's fluent API currently exposes expression and percentile.

make_udaf_expr_and_func!(
ApproxPercentileCont,
approx_percentile_cont,
expression percentile,
"Computes the approximate percentile continuous of a set of numbers",
approx_percentile_cont_udaf
);

However, as described in the datafusion docs, the UDAF accepts a 3rd optional argument, an integer number of centroids for T-Digest

impl ApproxPercentileCont {
/// Create a new [`ApproxPercentileCont`] aggregate function.
pub fn new() -> Self {
let mut variants = Vec::with_capacity(NUMERICS.len() * (INTEGERS.len() + 1));
// Accept any numeric value paired with a float64 percentile
for num in NUMERICS {
variants.push(TypeSignature::Exact(vec![num.clone(), DataType::Float64]));
// Additionally accept an integer number of centroids for T-Digest
for int in INTEGERS {
variants.push(TypeSignature::Exact(vec![
num.clone(),
DataType::Float64,
int.clone(),
]))
}
}
Self {
signature: Signature::one_of(variants, Volatility::Immutable),
}

Describe the solution you'd like

Consistent with exposing optional arguments for array_slice and regexp_* fluent apis, add a 3rd optional argument to approx_percentile_cont's fluent API.

Describe alternatives you've considered

No response

Additional context

I'll have a PR for this shortly.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions