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