-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Description
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:
datafusion/datafusion/core/src/physical_optimizer/aggregate_statistics.rs
Lines 185 to 186 in 569be9e
| if let Some(casted_expr) = | |
| agg_expr.as_any().downcast_ref::<expressions::Min>() |
datafusion/datafusion/core/src/physical_optimizer/aggregate_statistics.rs
Lines 197 to 198 in 569be9e
| if let Some(casted_expr) = | |
| agg_expr.as_any().downcast_ref::<expressions::Min>() |
datafusion/datafusion/core/src/physical_optimizer/aggregate_statistics.rs
Lines 235 to 236 in 569be9e
| if let Some(casted_expr) = | |
| agg_expr.as_any().downcast_ref::<expressions::Max>() |
datafusion/datafusion/core/src/physical_optimizer/aggregate_statistics.rs
Lines 247 to 248 in 569be9e
| 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_