1 | //===----------------------------------------------------------------------===// |
---|---|
2 | // DuckDB |
3 | // |
4 | // duckdb/planner/operator/logical_cteref.hpp |
5 | // |
6 | // |
7 | //===----------------------------------------------------------------------===// |
8 | |
9 | #pragma once |
10 | |
11 | #include "duckdb/common/types/chunk_collection.hpp" |
12 | #include "duckdb/planner/logical_operator.hpp" |
13 | |
14 | namespace duckdb { |
15 | |
16 | //! LogicalCTERef represents a reference to a recursive CTE |
17 | class LogicalCTERef : public LogicalOperator { |
18 | public: |
19 | static constexpr const LogicalOperatorType TYPE = LogicalOperatorType::LOGICAL_CTE_REF; |
20 | |
21 | public: |
22 | LogicalCTERef(idx_t table_index, idx_t cte_index, vector<LogicalType> types, vector<string> colnames) |
23 | : LogicalOperator(LogicalOperatorType::LOGICAL_CTE_REF), table_index(table_index), cte_index(cte_index) { |
24 | D_ASSERT(types.size() > 0); |
25 | chunk_types = types; |
26 | bound_columns = colnames; |
27 | } |
28 | |
29 | vector<string> bound_columns; |
30 | //! The table index in the current bind context |
31 | idx_t table_index; |
32 | //! CTE index |
33 | idx_t cte_index; |
34 | //! The types of the chunk |
35 | vector<LogicalType> chunk_types; |
36 | |
37 | public: |
38 | vector<ColumnBinding> GetColumnBindings() override { |
39 | return GenerateColumnBindings(table_idx: table_index, column_count: chunk_types.size()); |
40 | } |
41 | void Serialize(FieldWriter &writer) const override; |
42 | static unique_ptr<LogicalOperator> Deserialize(LogicalDeserializationState &state, FieldReader &reader); |
43 | vector<idx_t> GetTableIndex() const override; |
44 | string GetName() const override; |
45 | |
46 | protected: |
47 | void ResolveTypes() override { |
48 | // types are resolved in the constructor |
49 | this->types = chunk_types; |
50 | } |
51 | }; |
52 | } // namespace duckdb |
53 |