1 | #include "duckdb/planner/operator/logical_projection.hpp" |
---|---|
2 | |
3 | #include "duckdb/common/field_writer.hpp" |
4 | #include "duckdb/main/config.hpp" |
5 | |
6 | namespace duckdb { |
7 | |
8 | LogicalProjection::LogicalProjection(idx_t table_index, vector<unique_ptr<Expression>> select_list) |
9 | : LogicalOperator(LogicalOperatorType::LOGICAL_PROJECTION, std::move(select_list)), table_index(table_index) { |
10 | } |
11 | |
12 | vector<ColumnBinding> LogicalProjection::GetColumnBindings() { |
13 | return GenerateColumnBindings(table_idx: table_index, column_count: expressions.size()); |
14 | } |
15 | |
16 | void LogicalProjection::ResolveTypes() { |
17 | for (auto &expr : expressions) { |
18 | types.push_back(x: expr->return_type); |
19 | } |
20 | } |
21 | |
22 | void LogicalProjection::Serialize(FieldWriter &writer) const { |
23 | writer.WriteField(element: table_index); |
24 | writer.WriteSerializableList<Expression>(elements: expressions); |
25 | } |
26 | |
27 | unique_ptr<LogicalOperator> LogicalProjection::Deserialize(LogicalDeserializationState &state, FieldReader &reader) { |
28 | auto table_index = reader.ReadRequired<idx_t>(); |
29 | auto expressions = reader.ReadRequiredSerializableList<Expression>(args&: state.gstate); |
30 | return make_uniq<LogicalProjection>(args&: table_index, args: std::move(expressions)); |
31 | } |
32 | |
33 | vector<idx_t> LogicalProjection::GetTableIndex() const { |
34 | return vector<idx_t> {table_index}; |
35 | } |
36 | |
37 | string LogicalProjection::GetName() const { |
38 | #ifdef DEBUG |
39 | if (DBConfigOptions::debug_print_bindings) { |
40 | return LogicalOperator::GetName() + StringUtil::Format(" #%llu", table_index); |
41 | } |
42 | #endif |
43 | return LogicalOperator::GetName(); |
44 | } |
45 | |
46 | } // namespace duckdb |
47 |