1#include "duckdb/optimizer/statistics_propagator.hpp"
2#include "duckdb/planner/operator/logical_projection.hpp"
3
4namespace duckdb {
5
6unique_ptr<NodeStatistics> StatisticsPropagator::PropagateStatistics(LogicalProjection &proj,
7 unique_ptr<LogicalOperator> *node_ptr) {
8 // first propagate to the child
9 node_stats = PropagateStatistics(node_ptr&: proj.children[0]);
10 if (proj.children[0]->type == LogicalOperatorType::LOGICAL_EMPTY_RESULT) {
11 ReplaceWithEmptyResult(node&: *node_ptr);
12 return std::move(node_stats);
13 }
14
15 // then propagate to each of the expressions
16 for (idx_t i = 0; i < proj.expressions.size(); i++) {
17 auto stats = PropagateExpression(expr&: proj.expressions[i]);
18 if (stats) {
19 ColumnBinding binding(proj.table_index, i);
20 statistics_map.insert(x: make_pair(x&: binding, y: std::move(stats)));
21 }
22 }
23 return std::move(node_stats);
24}
25
26} // namespace duckdb
27