1 | #include "duckdb/optimizer/statistics_propagator.hpp" |
---|---|
2 | #include "duckdb/planner/expression/bound_aggregate_expression.hpp" |
3 | |
4 | namespace duckdb { |
5 | |
6 | unique_ptr<BaseStatistics> StatisticsPropagator::PropagateExpression(BoundAggregateExpression &aggr, |
7 | unique_ptr<Expression> *expr_ptr) { |
8 | vector<BaseStatistics> stats; |
9 | stats.reserve(n: aggr.children.size()); |
10 | for (auto &child : aggr.children) { |
11 | auto stat = PropagateExpression(expr&: child); |
12 | if (!stat) { |
13 | stats.push_back(x: BaseStatistics::CreateUnknown(type: child->return_type)); |
14 | } else { |
15 | stats.push_back(x: stat->Copy()); |
16 | } |
17 | } |
18 | if (!aggr.function.statistics) { |
19 | return nullptr; |
20 | } |
21 | AggregateStatisticsInput input(aggr.bind_info.get(), stats, node_stats.get()); |
22 | return aggr.function.statistics(context, aggr, input); |
23 | } |
24 | |
25 | } // namespace duckdb |
26 |