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