If pushing down the projection over this join's children seems possible, this function constructs the new [`ProjectionExec`]s that will come on top of the original children of the join.
(
projection_as_columns: &[(Column, String)],
far_right_left_col_ind: i32,
far_left_right_col_ind: i32,
left_child: &Arc<dyn ExecutionPlan>,
right_child: &Arc<dyn ExecutionPlan>,
)
| 845 | /// this function constructs the new [`ProjectionExec`]s that will come on top |
| 846 | /// of the original children of the join. |
| 847 | pub fn new_join_children( |
| 848 | projection_as_columns: &[(Column, String)], |
| 849 | far_right_left_col_ind: i32, |
| 850 | far_left_right_col_ind: i32, |
| 851 | left_child: &Arc<dyn ExecutionPlan>, |
| 852 | right_child: &Arc<dyn ExecutionPlan>, |
| 853 | ) -> Result<(ProjectionExec, ProjectionExec)> { |
| 854 | let new_left = ProjectionExec::try_new( |
| 855 | projection_as_columns[0..=far_right_left_col_ind as _] |
| 856 | .iter() |
| 857 | .map(|(col, alias)| ProjectionExpr { |
| 858 | expr: Arc::new(Column::new(col.name(), col.index())) as _, |
| 859 | alias: alias.clone(), |
| 860 | }), |
| 861 | Arc::clone(left_child), |
| 862 | )?; |
| 863 | let left_size = left_child.schema().fields().len() as i32; |
| 864 | let new_right = ProjectionExec::try_new( |
| 865 | projection_as_columns[far_left_right_col_ind as _..] |
| 866 | .iter() |
| 867 | .map(|(col, alias)| { |
| 868 | ProjectionExpr { |
| 869 | expr: Arc::new(Column::new( |
| 870 | col.name(), |
| 871 | // Align projected expressions coming from the right |
| 872 | // table with the new right child projection: |
| 873 | (col.index() as i32 - left_size) as _, |
| 874 | )) as _, |
| 875 | alias: alias.clone(), |
| 876 | } |
| 877 | }), |
| 878 | Arc::clone(right_child), |
| 879 | )?; |
| 880 | |
| 881 | Ok((new_left, new_right)) |
| 882 | } |
| 883 | |
| 884 | /// Checks three conditions for pushing a projection down through a join: |
| 885 | /// - Projection must narrow the join output schema. |
no test coverage detected
searching dependent graphs…