Skip to content

Remove special casting of Min / Max built in AggregateFunctions #11151

@alamb

Description

@alamb

Is your feature request related to a problem or challenge?

Part of #10943

While trying to port min and max to UDFs in #11013, @edmondop found several places where Min and Max (the existing built in aggregate functions) are special cased

Here is Max:

pub struct Max {
name: String,
data_type: DataType,
nullable: bool,
expr: Arc<dyn PhysicalExpr>,
}

The problem with relying on Min and Max directly is that it is hard/impossible to switch Min/Max to be a user defined aggregates as seen in #11013

Also, relying on Min/Max directly means that there is certain behavior that is not available to UDAFs compared to build in aggregate functions, which isn't ideal

Describe the solution you'd like

Remove all explicit references to Min / Max

Specifically, code that looks like this should be removed

       expr.as_any().downcast_ref::<Max>()

and

       expr.as_any().downcast_ref::<Min>()

Describe alternatives you've considered

Ideally, the alternative is to use a function on AggregateExpr which we can then add/implement for UDAFs when we port min/max to be a UDAF

Task List

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions