1//===----------------------------------------------------------------------===//
2// DuckDB
3//
4// duckdb/optimizer/common_aggregate_optimizer.hpp
5//
6//
7//===----------------------------------------------------------------------===//
8
9#pragma once
10
11#include "duckdb/planner/logical_operator_visitor.hpp"
12#include "duckdb/planner/column_binding_map.hpp"
13
14namespace duckdb {
15//! The CommonAggregateOptimizer optimizer eliminates duplicate aggregates from aggregate nodes
16class CommonAggregateOptimizer : public LogicalOperatorVisitor {
17public:
18 void VisitOperator(LogicalOperator &op) override;
19
20private:
21 unique_ptr<Expression> VisitReplace(BoundColumnRefExpression &expr, unique_ptr<Expression> *expr_ptr) override;
22
23 void ExtractCommonAggregates(LogicalAggregate &aggr);
24
25private:
26 column_binding_map_t<ColumnBinding> aggregate_map;
27};
28} // namespace duckdb
29