1//===----------------------------------------------------------------------===//
2// DuckDB
3//
4// duckdb/planner/operator/logical_aggregate.hpp
5//
6//
7//===----------------------------------------------------------------------===//
8
9#pragma once
10
11#include "duckdb/planner/logical_operator.hpp"
12#include "duckdb/planner/column_binding.hpp"
13#include "duckdb/storage/statistics/base_statistics.hpp"
14#include "duckdb/parser/group_by_node.hpp"
15
16namespace duckdb {
17
18//! LogicalAggregate represents an aggregate operation with (optional) GROUP BY
19//! operator.
20class LogicalAggregate : public LogicalOperator {
21public:
22 static constexpr const LogicalOperatorType TYPE = LogicalOperatorType::LOGICAL_AGGREGATE_AND_GROUP_BY;
23
24public:
25 LogicalAggregate(idx_t group_index, idx_t aggregate_index, vector<unique_ptr<Expression>> select_list);
26
27 //! The table index for the groups of the LogicalAggregate
28 idx_t group_index;
29 //! The table index for the aggregates of the LogicalAggregate
30 idx_t aggregate_index;
31 //! The table index for the GROUPING function calls of the LogicalAggregate
32 idx_t groupings_index;
33 //! The set of groups (optional).
34 vector<unique_ptr<Expression>> groups;
35 //! The set of grouping sets (optional).
36 vector<GroupingSet> grouping_sets;
37 //! The list of grouping function calls (optional)
38 vector<unsafe_vector<idx_t>> grouping_functions;
39 //! Group statistics (optional)
40 vector<unique_ptr<BaseStatistics>> group_stats;
41
42public:
43 string ParamsToString() const override;
44
45 vector<ColumnBinding> GetColumnBindings() override;
46 void Serialize(FieldWriter &writer) const override;
47 static unique_ptr<LogicalOperator> Deserialize(LogicalDeserializationState &state, FieldReader &reader);
48 idx_t EstimateCardinality(ClientContext &context) override;
49 vector<idx_t> GetTableIndex() const override;
50 string GetName() const override;
51
52protected:
53 void ResolveTypes() override;
54};
55} // namespace duckdb
56