Skip to content

Remove Min/Max references from AggregateStatistics #11153

@alamb

Description

@alamb

Is your feature request related to a problem or challenge?

Part of #11151 (where we are removing special case uses of Min/Max)

Describe the solution you'd like

Reemove these cases:

if let Some(casted_expr) =
agg_expr.as_any().downcast_ref::<expressions::Min>()

if let Some(casted_expr) =
agg_expr.as_any().downcast_ref::<expressions::Min>()

if let Some(casted_expr) =
agg_expr.as_any().downcast_ref::<expressions::Max>()

if let Some(casted_expr) =
agg_expr.as_any().downcast_ref::<expressions::Max>()

Specifically, the idea is to remove the pattern

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

and

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

Describe alternatives you've considered

I suggest adding a general purpose function to AggregateExec and then implementing it for Min and Max (so we can do the same for Min/Max UDAF)

impl AggregateExpr {

 /// Return the value of the aggregate function, if known, given the number of input rows.
 /// 
 /// Return None if the value can not be determined solely from the input.
 /// 
 /// # Examples
 /// * The `COUNT` aggregate would return `Some(11)` given `num_rows = 11`
 /// * The `MIN` aggregate would return `Some(Null)` given `num_rows = 0
 /// * The `MIN` aggregate would return `None` given num_rows = 11
 fn output_from_rows(&self, num_rows: usize) -> Option<ScalarValue> { None }
...
}

### Additional context

_No response_

Metadata

Metadata

Assignees

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