MCPcopy Create free account
hub / github.com/apache/datafusion / plan_aggregate

Method plan_aggregate

datafusion/functions-aggregate/src/planner.rs:33–115  ·  view source on GitHub ↗
(
        &self,
        raw_expr: RawAggregateExpr,
    )

Source from the content-addressed store, hash-verified

31
32impl ExprPlanner for AggregateFunctionPlanner {
33 fn plan_aggregate(
34 &self,
35 raw_expr: RawAggregateExpr,
36 ) -> Result<PlannerResult<RawAggregateExpr>> {
37 let RawAggregateExpr {
38 func,
39 args,
40 distinct,
41 filter,
42 order_by,
43 null_treatment,
44 } = raw_expr;
45
46 let origin_expr = Expr::AggregateFunction(AggregateFunction {
47 func,
48 params: AggregateFunctionParams {
49 args,
50 distinct,
51 filter,
52 order_by,
53 null_treatment,
54 },
55 });
56
57 let saved_name = NamePreserver::new_for_projection().save(&origin_expr);
58
59 let Expr::AggregateFunction(AggregateFunction {
60 func,
61 params:
62 AggregateFunctionParams {
63 args,
64 distinct,
65 filter,
66 order_by,
67 null_treatment,
68 },
69 }) = origin_expr
70 else {
71 unreachable!("")
72 };
73 let raw_expr = RawAggregateExpr {
74 func,
75 args,
76 distinct,
77 filter,
78 order_by,
79 null_treatment,
80 };
81
82 // handle count() and count(*) case
83 // convert to count(1) as "count()"
84 // or count(1) as "count(*)"
85 // TODO: remove the next line after `Expr::Wildcard` is removed
86 #[expect(deprecated)]
87 if raw_expr.func.name() == "count"
88 && (raw_expr.args.len() == 1
89 && matches!(raw_expr.args[0], Expr::Wildcard { .. })
90 || raw_expr.args.is_empty())

Callers

nothing calls this directly

Calls 6

restoreMethod · 0.80
AggregateFunctionClass · 0.50
saveMethod · 0.45
nameMethod · 0.45
lenMethod · 0.45
is_emptyMethod · 0.45

Tested by

no test coverage detected