@@ -61,7 +61,7 @@ use log::trace;
6161#[ derive( Debug , Clone ) ]
6262pub struct ProjectionExec {
6363 /// The projection expressions stored as tuples of (expression, output column name)
64- pub ( crate ) expr : Vec < ( Arc < dyn PhysicalExpr > , String ) > ,
64+ pub ( crate ) expr : Vec < ProjectionExpr > ,
6565 /// The schema once the projection has been applied to the input
6666 schema : SchemaRef ,
6767 /// The input plan
@@ -75,7 +75,7 @@ pub struct ProjectionExec {
7575impl ProjectionExec {
7676 /// Create a projection on an input
7777 pub fn try_new (
78- expr : Vec < ( Arc < dyn PhysicalExpr > , String ) > ,
78+ expr : Vec < ProjectionExpr > ,
7979 input : Arc < dyn ExecutionPlan > ,
8080 ) -> Result < Self > {
8181 let input_schema = input. schema ( ) ;
@@ -115,7 +115,7 @@ impl ProjectionExec {
115115 }
116116
117117 /// The projection expressions stored as tuples of (expression, output column name)
118- pub fn expr ( & self ) -> & [ ( Arc < dyn PhysicalExpr > , String ) ] {
118+ pub fn expr ( & self ) -> & [ ProjectionExpr ] {
119119 & self . expr
120120 }
121121
@@ -147,6 +147,8 @@ impl ProjectionExec {
147147 }
148148}
149149
150+ pub type ProjectionExpr = ( Arc < dyn PhysicalExpr > , String ) ;
151+
150152impl DisplayAs for ProjectionExec {
151153 fn fmt_as (
152154 & self ,
@@ -566,7 +568,7 @@ fn is_projection_removable(projection: &ProjectionExec) -> bool {
566568
567569/// Given the expression set of a projection, checks if the projection causes
568570/// any renaming or constructs a non-`Column` physical expression.
569- pub fn all_alias_free_columns ( exprs : & [ ( Arc < dyn PhysicalExpr > , String ) ] ) -> bool {
571+ pub fn all_alias_free_columns ( exprs : & [ ProjectionExpr ] ) -> bool {
570572 exprs. iter ( ) . all ( |( expr, alias) | {
571573 expr. as_any ( )
572574 . downcast_ref :: < Column > ( )
@@ -579,11 +581,10 @@ pub fn all_alias_free_columns(exprs: &[(Arc<dyn PhysicalExpr>, String)]) -> bool
579581/// projection operator's expressions. To use this function safely, one must
580582/// ensure that all expressions are `Column` expressions without aliases.
581583pub fn new_projections_for_columns (
582- projection : & ProjectionExec ,
584+ projection : & [ ProjectionExpr ] ,
583585 source : & [ usize ] ,
584586) -> Vec < usize > {
585587 projection
586- . expr ( )
587588 . iter ( )
588589 . filter_map ( |( expr, _) | {
589590 expr. as_any ( )
@@ -604,7 +605,7 @@ pub fn make_with_child(
604605}
605606
606607/// Returns `true` if all the expressions in the argument are `Column`s.
607- pub fn all_columns ( exprs : & [ ( Arc < dyn PhysicalExpr > , String ) ] ) -> bool {
608+ pub fn all_columns ( exprs : & [ ProjectionExpr ] ) -> bool {
608609 exprs. iter ( ) . all ( |( expr, _) | expr. as_any ( ) . is :: < Column > ( ) )
609610}
610611
@@ -627,7 +628,7 @@ pub fn all_columns(exprs: &[(Arc<dyn PhysicalExpr>, String)]) -> bool {
627628/// `a@0`, but `b@2` results in `None` since the projection does not include `b`.
628629pub fn update_expr (
629630 expr : & Arc < dyn PhysicalExpr > ,
630- projected_exprs : & [ ( Arc < dyn PhysicalExpr > , String ) ] ,
631+ projected_exprs : & [ ProjectionExpr ] ,
631632 sync_with_child : bool ,
632633) -> Result < Option < Arc < dyn PhysicalExpr > > > {
633634 #[ derive( Debug , PartialEq ) ]
@@ -692,7 +693,7 @@ pub fn update_expr(
692693/// expressions using the [`update_expr`] function.
693694pub fn update_ordering (
694695 ordering : LexOrdering ,
695- projected_exprs : & [ ( Arc < dyn PhysicalExpr > , String ) ] ,
696+ projected_exprs : & [ ProjectionExpr ] ,
696697) -> Result < Option < LexOrdering > > {
697698 let mut updated_exprs = vec ! [ ] ;
698699 for mut sort_expr in ordering. into_iter ( ) {
@@ -710,7 +711,7 @@ pub fn update_ordering(
710711/// expressions using the [`update_expr`] function.
711712pub fn update_ordering_requirement (
712713 reqs : LexRequirement ,
713- projected_exprs : & [ ( Arc < dyn PhysicalExpr > , String ) ] ,
714+ projected_exprs : & [ ProjectionExpr ] ,
714715) -> Result < Option < LexRequirement > > {
715716 let mut updated_exprs = vec ! [ ] ;
716717 for mut sort_expr in reqs. into_iter ( ) {
@@ -727,7 +728,7 @@ pub fn update_ordering_requirement(
727728/// Downcasts all the expressions in `exprs` to `Column`s. If any of the given
728729/// expressions is not a `Column`, returns `None`.
729730pub fn physical_to_column_exprs (
730- exprs : & [ ( Arc < dyn PhysicalExpr > , String ) ] ,
731+ exprs : & [ ProjectionExpr ] ,
731732) -> Option < Vec < ( Column , String ) > > {
732733 exprs
733734 . iter ( )
@@ -952,7 +953,7 @@ fn try_unifying_projections(
952953}
953954
954955/// Collect all column indices from the given projection expressions.
955- fn collect_column_indices ( exprs : & [ ( Arc < dyn PhysicalExpr > , String ) ] ) -> Vec < usize > {
956+ fn collect_column_indices ( exprs : & [ ProjectionExpr ] ) -> Vec < usize > {
956957 // Collect indices and remove duplicates.
957958 let mut indices = exprs
958959 . iter ( )
@@ -1314,7 +1315,7 @@ mod tests {
13141315 // of output schema columns < input schema columns and hence if we use the last few columns
13151316 // from the input schema in the expressions here, bounds_check would fail on them if output
13161317 // schema is supplied to the partitions_statistics method.
1317- let exprs: Vec < ( Arc < dyn PhysicalExpr > , String ) > = vec ! [
1318+ let exprs: Vec < ProjectionExpr > = vec ! [
13181319 (
13191320 Arc :: new( Column :: new( "c" , 2 ) ) as Arc <dyn PhysicalExpr >,
13201321 "c_renamed" . to_string( ) ,
0 commit comments