| 1 | #include "duckdb/optimizer/statistics_propagator.hpp" |
|---|---|
| 2 | #include "duckdb/planner/expression/bound_case_expression.hpp" |
| 3 | |
| 4 | namespace duckdb { |
| 5 | |
| 6 | unique_ptr<BaseStatistics> StatisticsPropagator::PropagateExpression(BoundCaseExpression &bound_case, |
| 7 | unique_ptr<Expression> *expr_ptr) { |
| 8 | // propagate in all the children |
| 9 | auto result_stats = PropagateExpression(expr&: bound_case.else_expr); |
| 10 | for (auto &case_check : bound_case.case_checks) { |
| 11 | PropagateExpression(expr&: case_check.when_expr); |
| 12 | auto then_stats = PropagateExpression(expr&: case_check.then_expr); |
| 13 | if (!then_stats) { |
| 14 | result_stats.reset(); |
| 15 | } else if (result_stats) { |
| 16 | result_stats->Merge(other: *then_stats); |
| 17 | } |
| 18 | } |
| 19 | return result_stats; |
| 20 | } |
| 21 | |
| 22 | } // namespace duckdb |
| 23 |