1 | #include "duckdb/execution/operator/helper/physical_load.hpp" |
2 | #include "duckdb/execution/operator/helper/physical_transaction.hpp" |
3 | #include "duckdb/execution/operator/helper/physical_vacuum.hpp" |
4 | #include "duckdb/execution/operator/schema/physical_alter.hpp" |
5 | #include "duckdb/execution/operator/schema/physical_attach.hpp" |
6 | #include "duckdb/execution/operator/schema/physical_create_schema.hpp" |
7 | #include "duckdb/execution/operator/schema/physical_create_sequence.hpp" |
8 | #include "duckdb/execution/operator/schema/physical_create_view.hpp" |
9 | #include "duckdb/execution/operator/schema/physical_detach.hpp" |
10 | #include "duckdb/execution/operator/schema/physical_drop.hpp" |
11 | #include "duckdb/execution/physical_plan_generator.hpp" |
12 | #include "duckdb/planner/logical_operator.hpp" |
13 | #include "duckdb/planner/operator/logical_simple.hpp" |
14 | |
15 | namespace duckdb { |
16 | |
17 | unique_ptr<PhysicalOperator> PhysicalPlanGenerator::CreatePlan(LogicalSimple &op) { |
18 | switch (op.type) { |
19 | case LogicalOperatorType::LOGICAL_ALTER: |
20 | return make_uniq<PhysicalAlter>(args: unique_ptr_cast<ParseInfo, AlterInfo>(src: std::move(op.info)), |
21 | args&: op.estimated_cardinality); |
22 | case LogicalOperatorType::LOGICAL_DROP: |
23 | return make_uniq<PhysicalDrop>(args: unique_ptr_cast<ParseInfo, DropInfo>(src: std::move(op.info)), |
24 | args&: op.estimated_cardinality); |
25 | case LogicalOperatorType::LOGICAL_TRANSACTION: |
26 | return make_uniq<PhysicalTransaction>(args: unique_ptr_cast<ParseInfo, TransactionInfo>(src: std::move(op.info)), |
27 | args&: op.estimated_cardinality); |
28 | case LogicalOperatorType::LOGICAL_VACUUM: { |
29 | auto result = make_uniq<PhysicalVacuum>(args: unique_ptr_cast<ParseInfo, VacuumInfo>(src: std::move(op.info)), |
30 | args&: op.estimated_cardinality); |
31 | if (!op.children.empty()) { |
32 | auto child = CreatePlan(op&: *op.children[0]); |
33 | result->children.push_back(x: std::move(child)); |
34 | } |
35 | return std::move(result); |
36 | } |
37 | case LogicalOperatorType::LOGICAL_LOAD: |
38 | return make_uniq<PhysicalLoad>(args: unique_ptr_cast<ParseInfo, LoadInfo>(src: std::move(op.info)), |
39 | args&: op.estimated_cardinality); |
40 | case LogicalOperatorType::LOGICAL_ATTACH: |
41 | return make_uniq<PhysicalAttach>(args: unique_ptr_cast<ParseInfo, AttachInfo>(src: std::move(op.info)), |
42 | args&: op.estimated_cardinality); |
43 | case LogicalOperatorType::LOGICAL_DETACH: |
44 | return make_uniq<PhysicalDetach>(args: unique_ptr_cast<ParseInfo, DetachInfo>(src: std::move(op.info)), |
45 | args&: op.estimated_cardinality); |
46 | default: |
47 | throw NotImplementedException("Unimplemented type for logical simple operator" ); |
48 | } |
49 | } |
50 | |
51 | } // namespace duckdb |
52 | |