Skip to content

Commit

Permalink
add sum(count) case in PushDownProjection
Browse files Browse the repository at this point in the history
  • Loading branch information
lutengda authored and roseboy-liu committed Oct 24, 2024
1 parent f6c50a7 commit ce4ee92
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion datafusion/optimizer/src/push_down_projection.rs
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,13 @@ impl OptimizerRule for PushDownProjection {
fun, args, ..
}) = &agg.aggr_expr[0]
{
if matches!(fun, datafusion_expr::AggregateFunction::Count)
if matches!(fun, datafusion_expr::AggregateFunction::Sum) && args.len() == 1 {
if let Expr::Column(Column { relation, name }) = &args[0] {
if relation.is_none() && name == "COUNT(UInt8(1))" {
new_aggr_expr.push(agg.aggr_expr[0].clone());
}
}
} else if matches!(fun, datafusion_expr::AggregateFunction::Count)
&& args.len() == 1
&& args[0] == Expr::Literal(UInt8(Some(1)))
{
Expand Down

0 comments on commit ce4ee92

Please sign in to comment.