Skip to content

AggregateFnProperties #7843

Open
Open

Description

@gatesn
pub struct AggregateFnProperties {
    pub order_sensitivity: AggregateOrderSensitivity,
    pub partial_aggregation: PartialAggregation,
    pub distinct_sensitivity: DistinctSensitivity,
}

pub enum AggregateOrderSensitivity {
    Insensitive, // planner may reorder input rows
    Sensitive,   // input order is part of the result
}

pub enum PartialAggregation {
    Unsupported,  // do not introduce partial/final aggregation
    OrderedMerge, // may split contiguous input, must merge partials in input order
    UnorderedMerge, // may split/repartition and merge partials in any order/tree
}

pub enum DistinctSensitivity {
    Sensitive,
    Insensitive, // agg(DISTINCT x) == agg(x)
}

trait AggregateFnVTable {
  ...
  fn properties(&self, options: &Self::Options, input_dtype: &DType) -> AggregateFnProperties;
}
Aggregate Properties
count, nan_count order-insensitive, unordered-merge
min_max order-insensitive, unordered-merge, distinct-insensitive
is_constant likely order-insensitive, unordered-merge
first, last, is_sorted order-sensitive, ordered-merge
sum(bool), sum(unsigned) order-insensitive, unordered-merge
sum(signed), sum(decimal), sum(float) order-sensitive, partial aggregation unsupported under strict Vortex semantics
mean inherits sum’s dtype caveats

Activity

  1. joseph-isaacs commented on May 8, 2026

    @joseph-isaacs
    Contributor

    We are really asking the question AggregateOrderSensitivity is that operation commutative?

    For PartialAggregation we are asking is the merge over the partial OrderedMerge -> associative and UnorderedMerge -> associative + commutative

    For DistinctSensitivity is the partial idempotent

  2. joseph-isaacs commented on May 8, 2026

    @joseph-isaacs
    Contributor

    we could get away with

    AggregateOperationProperties  {
      commutative: bool
    }
    
    PartialMergeProperties {
      commutative: bool
      associative: bool
      idempotent: bool
    }
    
  3. joseph-isaacs commented on May 8, 2026

    @joseph-isaacs
    Contributor

    Or maybe we have a single operator struct

    OperatorProperties {
        commutative: bool
        associative: bool
        idempotent: bool
    }
    

    Then this can be used for aggregations and overwritten for partial merge since aggregation op properties ==> partial merge properties.

  4. gatesn commented on May 8, 2026

    @gatesn
    ContributorAuthor

    I think you want to stick to the domain-specific meaning, rather than infer it from low level properties.

    e.g. is last(...) idempotent? I find I have to think much harder about it...

  5. joseph-isaacs commented on May 8, 2026

    @joseph-isaacs
    Contributor

    its not, but its not clear in both cases?

  6. joseph-isaacs commented on May 8, 2026

    @joseph-isaacs
    Contributor

    Okay but can we have the same meaning for both operators. agg and lifted agg (over partial).

    If we use associative and commutative then we can use the same definition for aggregations and scalar_fns. I guess we could infer these but right now these are a little muddled.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions