@@ -11,26 +11,22 @@ use anyhow::anyhow;
1111use anyhow:: Result ;
1212use crate :: execution_v1:: physical_plan:: physical_filter:: PhysicalFilter ;
1313use crate :: execution_v1:: physical_plan:: physical_insert:: PhysicalInsert ;
14+ use crate :: execution_v1:: physical_plan:: physical_limit:: PhysicalLimit ;
15+ use crate :: execution_v1:: physical_plan:: physical_sort:: PhysicalSort ;
1416use crate :: execution_v1:: physical_plan:: physical_values:: PhysicalValues ;
1517use crate :: planner:: logical_insert_plan:: LogicalInsertPlan ;
1618use crate :: planner:: operator:: filter:: FilterOperator ;
1719use crate :: planner:: operator:: insert:: InsertOperator ;
20+ use crate :: planner:: operator:: limit:: LimitOperator ;
1821use crate :: planner:: operator:: project:: ProjectOperator ;
22+ use crate :: planner:: operator:: sort:: SortOperator ;
1923use crate :: planner:: operator:: values:: ValuesOperator ;
2024
21- pub struct PhysicalPlanBuilder {
22- plan_id : u32 ,
23- }
25+ pub struct PhysicalPlanBuilder { }
2426
2527impl PhysicalPlanBuilder {
2628 pub fn new ( ) -> Self {
27- PhysicalPlanBuilder { plan_id : 0 }
28- }
29-
30- fn next_plan_id ( & mut self ) -> u32 {
31- let id = self . plan_id ;
32- self . plan_id += 1 ;
33- id
29+ PhysicalPlanBuilder { }
3430 }
3531
3632 pub fn build_plan ( & mut self , plan : & LogicalPlan ) -> Result < PhysicalOperator > {
@@ -87,6 +83,8 @@ impl PhysicalPlanBuilder {
8783 Operator :: Project ( op) => self . build_physical_select_projection ( plan, op) ,
8884 Operator :: Scan ( scan) => Ok ( self . build_physical_scan ( scan. clone ( ) ) ) ,
8985 Operator :: Filter ( op) => self . build_physical_filter ( plan, op) ,
86+ Operator :: Sort ( op) => self . build_physical_sort ( plan, op) ,
87+ Operator :: Limit ( op) =>self . build_physical_limit ( plan, op) ,
9088 _ => Err ( anyhow ! ( format!(
9189 "Unsupported physical plan: {:?}" ,
9290 plan. operator
@@ -98,23 +96,39 @@ impl PhysicalPlanBuilder {
9896 let input = self . build_select_logical_plan ( plan. child ( 0 ) ?) ?;
9997
10098 Ok ( PhysicalOperator :: Projection ( PhysicalProjection {
101- plan_id : self . next_plan_id ( ) ,
10299 exprs : op. columns . clone ( ) ,
103100 input : Box :: new ( input) ,
104101 } ) )
105102 }
106103
107104 fn build_physical_scan ( & mut self , base : ScanOperator ) -> PhysicalOperator {
108- PhysicalOperator :: TableScan ( PhysicalTableScan { plan_id : self . next_plan_id ( ) , base } )
105+ PhysicalOperator :: TableScan ( PhysicalTableScan { base } )
109106 }
110107
111108 fn build_physical_filter ( & mut self , plan : & LogicalSelectPlan , base : & FilterOperator ) -> Result < PhysicalOperator > {
112109 let input = self . build_select_logical_plan ( plan. child ( 0 ) ?) ?;
113110
114111 Ok ( PhysicalOperator :: Filter ( PhysicalFilter {
115- plan_id : 0 ,
116112 predicate : base. predicate . clone ( ) ,
117113 input : Box :: new ( input) ,
118114 } ) )
119115 }
116+
117+ fn build_physical_sort ( & mut self , plan : & LogicalSelectPlan , base : & SortOperator ) -> Result < PhysicalOperator > {
118+ let input = self . build_select_logical_plan ( plan. child ( 0 ) ?) ?;
119+
120+ Ok ( PhysicalOperator :: Sort ( PhysicalSort {
121+ op : base. clone ( ) ,
122+ input : Box :: new ( input) ,
123+ } ) )
124+ }
125+
126+ fn build_physical_limit ( & mut self , plan : & LogicalSelectPlan , base : & LimitOperator ) ->Result < PhysicalOperator > {
127+ let input =self . build_select_logical_plan ( plan. child ( 0 ) ?) ?;
128+
129+ Ok ( PhysicalOperator :: Limit ( PhysicalLimit {
130+ op : base. clone ( ) ,
131+ input : Box :: new ( input) ,
132+ } ) )
133+ }
120134}
0 commit comments