@@ -11,26 +11,20 @@ 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_sort:: PhysicalSort ;
1415use crate :: execution_v1:: physical_plan:: physical_values:: PhysicalValues ;
1516use crate :: planner:: logical_insert_plan:: LogicalInsertPlan ;
1617use crate :: planner:: operator:: filter:: FilterOperator ;
1718use crate :: planner:: operator:: insert:: InsertOperator ;
1819use crate :: planner:: operator:: project:: ProjectOperator ;
20+ use crate :: planner:: operator:: sort:: SortOperator ;
1921use crate :: planner:: operator:: values:: ValuesOperator ;
2022
21- pub struct PhysicalPlanBuilder {
22- plan_id : u32 ,
23- }
23+ pub struct PhysicalPlanBuilder { }
2424
2525impl PhysicalPlanBuilder {
2626 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
27+ PhysicalPlanBuilder { }
3428 }
3529
3630 pub fn build_plan ( & mut self , plan : & LogicalPlan ) -> Result < PhysicalOperator > {
@@ -87,6 +81,7 @@ impl PhysicalPlanBuilder {
8781 Operator :: Project ( op) => self . build_physical_select_projection ( plan, op) ,
8882 Operator :: Scan ( scan) => Ok ( self . build_physical_scan ( scan. clone ( ) ) ) ,
8983 Operator :: Filter ( op) => self . build_physical_filter ( plan, op) ,
84+ Operator :: Sort ( op) => self . build_physical_sort ( plan, op) ,
9085 _ => Err ( anyhow ! ( format!(
9186 "Unsupported physical plan: {:?}" ,
9287 plan. operator
@@ -98,23 +93,30 @@ impl PhysicalPlanBuilder {
9893 let input = self . build_select_logical_plan ( plan. child ( 0 ) ?) ?;
9994
10095 Ok ( PhysicalOperator :: Projection ( PhysicalProjection {
101- plan_id : self . next_plan_id ( ) ,
10296 exprs : op. columns . clone ( ) ,
10397 input : Box :: new ( input) ,
10498 } ) )
10599 }
106100
107101 fn build_physical_scan ( & mut self , base : ScanOperator ) -> PhysicalOperator {
108- PhysicalOperator :: TableScan ( PhysicalTableScan { plan_id : self . next_plan_id ( ) , base } )
102+ PhysicalOperator :: TableScan ( PhysicalTableScan { base } )
109103 }
110104
111105 fn build_physical_filter ( & mut self , plan : & LogicalSelectPlan , base : & FilterOperator ) -> Result < PhysicalOperator > {
112106 let input = self . build_select_logical_plan ( plan. child ( 0 ) ?) ?;
113107
114108 Ok ( PhysicalOperator :: Filter ( PhysicalFilter {
115- plan_id : 0 ,
116109 predicate : base. predicate . clone ( ) ,
117110 input : Box :: new ( input) ,
118111 } ) )
119112 }
113+
114+ fn build_physical_sort ( & mut self , plan : & LogicalSelectPlan , base : & SortOperator ) -> Result < PhysicalOperator > {
115+ let input = self . build_select_logical_plan ( plan. child ( 0 ) ?) ?;
116+
117+ Ok ( PhysicalOperator :: Sort ( PhysicalSort {
118+ op : base. clone ( ) ,
119+ input : Box :: new ( input) ,
120+ } ) )
121+ }
120122}
0 commit comments