| 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 | #include "duckdb/parser/parsed_data/sample_options.hpp" |
| 16 | #include "duckdb/parser/group_by_node.hpp" |
| 17 | #include "duckdb/common/enums/aggregate_handling.hpp" |
| 18 | |
| 19 | namespace duckdb { |
| 20 | |
| 21 | //! SelectNode represents a standard SELECT statement |
| 22 | class SelectNode : public QueryNode { |
| 23 | public: |
| 24 | static constexpr const QueryNodeType TYPE = QueryNodeType::SELECT_NODE; |
| 25 | |
| 26 | public: |
| 27 | DUCKDB_API SelectNode(); |
| 28 | |
| 29 | //! The projection list |
| 30 | vector<unique_ptr<ParsedExpression>> select_list; |
| 31 | //! The FROM clause |
| 32 | unique_ptr<TableRef> from_table; |
| 33 | //! The WHERE clause |
| 34 | unique_ptr<ParsedExpression> where_clause; |
| 35 | //! list of groups |
| 36 | GroupByNode groups; |
| 37 | //! HAVING clause |
| 38 | unique_ptr<ParsedExpression> having; |
| 39 | //! QUALIFY clause |
| 40 | unique_ptr<ParsedExpression> qualify; |
| 41 | //! Aggregate handling during binding |
| 42 | AggregateHandling aggregate_handling; |
| 43 | //! The SAMPLE clause |
| 44 | unique_ptr<SampleOptions> sample; |
| 45 | |
| 46 | const vector<unique_ptr<ParsedExpression>> &GetSelectList() const override { |
| 47 | return select_list; |
| 48 | } |
| 49 | |
| 50 | public: |
| 51 | //! Convert the query node to a string |
| 52 | string ToString() const override; |
| 53 | |
| 54 | bool Equals(const QueryNode *other) const override; |
| 55 | |
| 56 | //! Create a copy of this SelectNode |
| 57 | unique_ptr<QueryNode> Copy() const override; |
| 58 | |
| 59 | //! Serializes a QueryNode to a stand-alone binary blob |
| 60 | void Serialize(FieldWriter &writer) const override; |
| 61 | |
| 62 | //! Deserializes a blob back into a QueryNode |
| 63 | static unique_ptr<QueryNode> Deserialize(FieldReader &reader); |
| 64 | |
| 65 | void FormatSerialize(FormatSerializer &serializer) const override; |
| 66 | static unique_ptr<QueryNode> FormatDeserialize(FormatDeserializer &deserializer); |
| 67 | }; |
| 68 | |
| 69 | } // namespace duckdb |
| 70 |