1#include "duckdb/execution/operator/schema/physical_create_function.hpp"
2#include "duckdb/execution/operator/schema/physical_create_schema.hpp"
3#include "duckdb/execution/operator/schema/physical_create_sequence.hpp"
4#include "duckdb/execution/operator/schema/physical_create_type.hpp"
5#include "duckdb/execution/operator/schema/physical_create_view.hpp"
6#include "duckdb/execution/physical_plan_generator.hpp"
7#include "duckdb/parser/parsed_data/create_type_info.hpp"
8#include "duckdb/planner/logical_operator.hpp"
9#include "duckdb/planner/operator/logical_create.hpp"
10
11namespace duckdb {
12
13unique_ptr<PhysicalOperator> PhysicalPlanGenerator::CreatePlan(LogicalCreate &op) {
14 switch (op.type) {
15 case LogicalOperatorType::LOGICAL_CREATE_SEQUENCE:
16 return make_uniq<PhysicalCreateSequence>(args: unique_ptr_cast<CreateInfo, CreateSequenceInfo>(src: std::move(op.info)),
17 args&: op.estimated_cardinality);
18 case LogicalOperatorType::LOGICAL_CREATE_VIEW:
19 return make_uniq<PhysicalCreateView>(args: unique_ptr_cast<CreateInfo, CreateViewInfo>(src: std::move(op.info)),
20 args&: op.estimated_cardinality);
21 case LogicalOperatorType::LOGICAL_CREATE_SCHEMA:
22 return make_uniq<PhysicalCreateSchema>(args: unique_ptr_cast<CreateInfo, CreateSchemaInfo>(src: std::move(op.info)),
23 args&: op.estimated_cardinality);
24 case LogicalOperatorType::LOGICAL_CREATE_MACRO:
25 return make_uniq<PhysicalCreateFunction>(args: unique_ptr_cast<CreateInfo, CreateMacroInfo>(src: std::move(op.info)),
26 args&: op.estimated_cardinality);
27 case LogicalOperatorType::LOGICAL_CREATE_TYPE: {
28 unique_ptr<PhysicalOperator> create = make_uniq<PhysicalCreateType>(
29 args: unique_ptr_cast<CreateInfo, CreateTypeInfo>(src: std::move(op.info)), args&: op.estimated_cardinality);
30 if (!op.children.empty()) {
31 D_ASSERT(op.children.size() == 1);
32 auto plan = CreatePlan(op&: *op.children[0]);
33 create->children.push_back(x: std::move(plan));
34 }
35 return create;
36 }
37 default:
38 throw NotImplementedException("Unimplemented type for logical simple create");
39 }
40}
41
42} // namespace duckdb
43