1#include "duckdb/optimizer/statistics_propagator.hpp"
2#include "duckdb/planner/expression/bound_window_expression.hpp"
3#include "duckdb/planner/operator/logical_window.hpp"
4
5namespace duckdb {
6
7unique_ptr<NodeStatistics> StatisticsPropagator::PropagateStatistics(LogicalWindow &window,
8 unique_ptr<LogicalOperator> *node_ptr) {
9 // first propagate to the child
10 node_stats = PropagateStatistics(node_ptr&: window.children[0]);
11
12 // then propagate to each of the order expressions
13 for (auto &window_expr : window.expressions) {
14 auto over_expr = reinterpret_cast<BoundWindowExpression *>(window_expr.get());
15 for (auto &expr : over_expr->partitions) {
16 over_expr->partitions_stats.push_back(x: PropagateExpression(expr));
17 }
18 for (auto &bound_order : over_expr->orders) {
19 bound_order.stats = PropagateExpression(expr&: bound_order.expression);
20 }
21 }
22 return std::move(node_stats);
23}
24
25} // namespace duckdb
26