@@ -7,10 +7,12 @@ use crate::{ops::*, PartitionScheme, PartitionSpec};
77#[ derive( Clone , Debug ) ]
88pub enum LogicalPlan {
99 Source ( Source ) ,
10+ Project ( Project ) ,
1011 Filter ( Filter ) ,
1112 Limit ( Limit ) ,
1213 Sort ( Sort ) ,
1314 Repartition ( Repartition ) ,
15+ Coalesce ( Coalesce ) ,
1416 Distinct ( Distinct ) ,
1517 Aggregate ( Aggregate ) ,
1618 Concat ( Concat ) ,
@@ -21,10 +23,14 @@ impl LogicalPlan {
2123 pub fn schema ( & self ) -> SchemaRef {
2224 match self {
2325 Self :: Source ( Source { schema, .. } ) => schema. clone ( ) ,
26+ Self :: Project ( Project {
27+ projected_schema, ..
28+ } ) => projected_schema. clone ( ) ,
2429 Self :: Filter ( Filter { input, .. } ) => input. schema ( ) ,
2530 Self :: Limit ( Limit { input, .. } ) => input. schema ( ) ,
2631 Self :: Sort ( Sort { input, .. } ) => input. schema ( ) ,
2732 Self :: Repartition ( Repartition { input, .. } ) => input. schema ( ) ,
33+ Self :: Coalesce ( Coalesce { input, .. } ) => input. schema ( ) ,
2834 Self :: Distinct ( Distinct { input, .. } ) => input. schema ( ) ,
2935 Self :: Aggregate ( aggregate) => aggregate. schema ( ) ,
3036 Self :: Concat ( Concat { input, .. } ) => input. schema ( ) ,
@@ -35,6 +41,7 @@ impl LogicalPlan {
3541 pub fn partition_spec ( & self ) -> Arc < PartitionSpec > {
3642 match self {
3743 Self :: Source ( Source { partition_spec, .. } ) => partition_spec. clone ( ) ,
44+ Self :: Project ( Project { input, .. } ) => input. partition_spec ( ) ,
3845 Self :: Filter ( Filter { input, .. } ) => input. partition_spec ( ) ,
3946 Self :: Limit ( Limit { input, .. } ) => input. partition_spec ( ) ,
4047 Self :: Sort ( Sort { input, sort_by, .. } ) => PartitionSpec :: new_internal (
@@ -54,6 +61,9 @@ impl LogicalPlan {
5461 Some ( partition_by. clone ( ) ) ,
5562 )
5663 . into ( ) ,
64+ Self :: Coalesce ( Coalesce { num_to, .. } ) => {
65+ PartitionSpec :: new_internal ( PartitionScheme :: Unknown , * num_to, None ) . into ( )
66+ }
5767 Self :: Distinct ( Distinct { input, .. } ) => input. partition_spec ( ) ,
5868 Self :: Aggregate ( Aggregate { input, .. } ) => input. partition_spec ( ) , // TODO
5969 Self :: Concat ( Concat { input, other } ) => PartitionSpec :: new_internal (
@@ -69,10 +79,12 @@ impl LogicalPlan {
6979 pub fn children ( & self ) -> Vec < & Self > {
7080 match self {
7181 Self :: Source ( ..) => vec ! [ ] ,
82+ Self :: Project ( Project { input, .. } ) => vec ! [ input] ,
7283 Self :: Filter ( Filter { input, .. } ) => vec ! [ input] ,
7384 Self :: Limit ( Limit { input, .. } ) => vec ! [ input] ,
7485 Self :: Sort ( Sort { input, .. } ) => vec ! [ input] ,
7586 Self :: Repartition ( Repartition { input, .. } ) => vec ! [ input] ,
87+ Self :: Coalesce ( Coalesce { input, .. } ) => vec ! [ input] ,
7688 Self :: Distinct ( Distinct { input, .. } ) => vec ! [ input] ,
7789 Self :: Aggregate ( Aggregate { input, .. } ) => vec ! [ input] ,
7890 Self :: Concat ( Concat { input, other } ) => vec ! [ input, other] ,
@@ -83,10 +95,12 @@ impl LogicalPlan {
8395 pub fn multiline_display ( & self ) -> Vec < String > {
8496 match self {
8597 Self :: Source ( source) => source. multiline_display ( ) ,
98+ Self :: Project ( Project { projection, .. } ) => vec ! [ format!( "Project: {projection:?}" ) ] ,
8699 Self :: Filter ( Filter { predicate, .. } ) => vec ! [ format!( "Filter: {predicate}" ) ] ,
87100 Self :: Limit ( Limit { limit, .. } ) => vec ! [ format!( "Limit: {limit}" ) ] ,
88101 Self :: Sort ( sort) => sort. multiline_display ( ) ,
89102 Self :: Repartition ( repartition) => repartition. multiline_display ( ) ,
103+ Self :: Coalesce ( Coalesce { num_to, .. } ) => vec ! [ format!( "Coalesce: {num_to}" ) ] ,
90104 Self :: Distinct ( _) => vec ! [ "Distinct" . to_string( ) ] ,
91105 Self :: Aggregate ( aggregate) => aggregate. multiline_display ( ) ,
92106 Self :: Concat ( _) => vec ! [ "Concat" . to_string( ) ] ,
@@ -112,10 +126,12 @@ macro_rules! impl_from_data_struct_for_logical_plan {
112126}
113127
114128impl_from_data_struct_for_logical_plan ! ( Source ) ;
129+ impl_from_data_struct_for_logical_plan ! ( Project ) ;
115130impl_from_data_struct_for_logical_plan ! ( Filter ) ;
116131impl_from_data_struct_for_logical_plan ! ( Limit ) ;
117132impl_from_data_struct_for_logical_plan ! ( Sort ) ;
118133impl_from_data_struct_for_logical_plan ! ( Repartition ) ;
134+ impl_from_data_struct_for_logical_plan ! ( Coalesce ) ;
119135impl_from_data_struct_for_logical_plan ! ( Distinct ) ;
120136impl_from_data_struct_for_logical_plan ! ( Aggregate ) ;
121137impl_from_data_struct_for_logical_plan ! ( Concat ) ;
0 commit comments