1//===----------------------------------------------------------------------===//
2// DuckDB
3//
4// duckdb/planner/bound_query_node.hpp
5//
6//
7//===----------------------------------------------------------------------===//
8
9#pragma once
10
11#include "duckdb/planner/expression.hpp"
12#include "duckdb/planner/bound_result_modifier.hpp"
13#include "duckdb/parser/query_node.hpp"
14
15namespace duckdb {
16
17//! Bound equivalent of QueryNode
18class BoundQueryNode {
19public:
20 explicit BoundQueryNode(QueryNodeType type) : type(type) {
21 }
22 virtual ~BoundQueryNode() {
23 }
24
25 //! The type of the query node, either SetOperation or Select
26 QueryNodeType type;
27 //! The result modifiers that should be applied to this query node
28 vector<unique_ptr<BoundResultModifier>> modifiers;
29
30 //! The names returned by this QueryNode.
31 vector<string> names;
32 //! The types returned by this QueryNode.
33 vector<LogicalType> types;
34
35public:
36 virtual idx_t GetRootIndex() = 0;
37
38public:
39 template <class TARGET>
40 TARGET &Cast() {
41 if (type != TARGET::TYPE) {
42 throw InternalException("Failed to cast bound query node to type - query node type mismatch");
43 }
44 return reinterpret_cast<TARGET &>(*this);
45 }
46
47 template <class TARGET>
48 const TARGET &Cast() const {
49 if (type != TARGET::TYPE) {
50 throw InternalException("Failed to cast bound query node to type - query node type mismatch");
51 }
52 return reinterpret_cast<const TARGET &>(*this);
53 }
54};
55
56} // namespace duckdb
57