1//===----------------------------------------------------------------------===//
2// DuckDB
3//
4// duckdb/parser/query_node/select_node.hpp
5//
6//
7//===----------------------------------------------------------------------===//
8
9#pragma once
10
11#include "duckdb/parser/parsed_expression.hpp"
12#include "duckdb/parser/query_node.hpp"
13#include "duckdb/parser/sql_statement.hpp"
14#include "duckdb/parser/tableref.hpp"
15
16namespace duckdb {
17
18enum class AggregateHandling : uint8_t {
19 STANDARD_HANDLING, // standard handling as in the SELECT clause
20 NO_AGGREGATES_ALLOWED, // no aggregates allowed: any aggregates in this node will result in an error
21 FORCE_AGGREGATES // force aggregates: any non-aggregate select list entry will become a GROUP
22};
23
24//! SelectNode represents a standard SELECT statement
25class SelectNode : public QueryNode {
26public:
27 SelectNode() : QueryNode(QueryNodeType::SELECT_NODE), aggregate_handling(AggregateHandling::STANDARD_HANDLING) {
28 }
29
30 //! The projection list
31 vector<unique_ptr<ParsedExpression>> select_list;
32 //! The FROM clause
33 unique_ptr<TableRef> from_table;
34 //! The WHERE clause
35 unique_ptr<ParsedExpression> where_clause;
36 //! list of groups
37 vector<unique_ptr<ParsedExpression>> groups;
38 //! HAVING clause
39 unique_ptr<ParsedExpression> having;
40 //! Aggregate handling during binding
41 AggregateHandling aggregate_handling;
42
43 const vector<unique_ptr<ParsedExpression>> &GetSelectList() const override {
44 return select_list;
45 }
46
47public:
48 bool Equals(const QueryNode *other) const override;
49 //! Create a copy of this SelectNode
50 unique_ptr<QueryNode> Copy() override;
51 //! Serializes a SelectNode to a stand-alone binary blob
52 void Serialize(Serializer &serializer) override;
53 //! Deserializes a blob back into a SelectNode
54 static unique_ptr<QueryNode> Deserialize(Deserializer &source);
55};
56}; // namespace duckdb
57