1#include "duckdb/execution/operator/order/physical_order.hpp"
2#include "duckdb/execution/physical_plan_generator.hpp"
3#include "duckdb/planner/operator/logical_order.hpp"
4
5namespace duckdb {
6
7unique_ptr<PhysicalOperator> PhysicalPlanGenerator::CreatePlan(LogicalOrder &op) {
8 D_ASSERT(op.children.size() == 1);
9
10 auto plan = CreatePlan(op&: *op.children[0]);
11 if (!op.orders.empty()) {
12 vector<idx_t> projections;
13 if (op.projections.empty()) {
14 for (idx_t i = 0; i < plan->types.size(); i++) {
15 projections.push_back(x: i);
16 }
17 } else {
18 projections = std::move(op.projections);
19 }
20 auto order =
21 make_uniq<PhysicalOrder>(args&: op.types, args: std::move(op.orders), args: std::move(projections), args&: op.estimated_cardinality);
22 order->children.push_back(x: std::move(plan));
23 plan = std::move(order);
24 }
25 return plan;
26}
27
28} // namespace duckdb
29