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