(
projection: &ProjectionExec,
join_left: &Arc<dyn ExecutionPlan>,
join_right: &Arc<dyn ExecutionPlan>,
join_on: JoinOnRef,
schema: &SchemaRef,
filter: Option<&JoinFilter>,
)
| 644 | } |
| 645 | |
| 646 | pub fn try_pushdown_through_join( |
| 647 | projection: &ProjectionExec, |
| 648 | join_left: &Arc<dyn ExecutionPlan>, |
| 649 | join_right: &Arc<dyn ExecutionPlan>, |
| 650 | join_on: JoinOnRef, |
| 651 | schema: &SchemaRef, |
| 652 | filter: Option<&JoinFilter>, |
| 653 | ) -> Result<Option<JoinData>> { |
| 654 | // Convert projected expressions to columns. We can not proceed if this is not possible. |
| 655 | let Some(projection_as_columns) = physical_to_column_exprs(projection.expr()) else { |
| 656 | return Ok(None); |
| 657 | }; |
| 658 | |
| 659 | let (far_right_left_col_ind, far_left_right_col_ind) = |
| 660 | join_table_borders(join_left.schema().fields().len(), &projection_as_columns); |
| 661 | |
| 662 | if !join_allows_pushdown( |
| 663 | &projection_as_columns, |
| 664 | schema, |
| 665 | far_right_left_col_ind, |
| 666 | far_left_right_col_ind, |
| 667 | ) { |
| 668 | return Ok(None); |
| 669 | } |
| 670 | |
| 671 | let new_filter = if let Some(filter) = filter { |
| 672 | match update_join_filter( |
| 673 | &projection_as_columns[0..=far_right_left_col_ind as _], |
| 674 | &projection_as_columns[far_left_right_col_ind as _..], |
| 675 | filter, |
| 676 | join_left.schema().fields().len(), |
| 677 | ) { |
| 678 | Some(updated_filter) => Some(updated_filter), |
| 679 | None => return Ok(None), |
| 680 | } |
| 681 | } else { |
| 682 | None |
| 683 | }; |
| 684 | |
| 685 | let Some(new_on) = update_join_on( |
| 686 | &projection_as_columns[0..=far_right_left_col_ind as _], |
| 687 | &projection_as_columns[far_left_right_col_ind as _..], |
| 688 | join_on, |
| 689 | join_left.schema().fields().len(), |
| 690 | ) else { |
| 691 | return Ok(None); |
| 692 | }; |
| 693 | |
| 694 | let (new_left, new_right) = new_join_children( |
| 695 | &projection_as_columns, |
| 696 | far_right_left_col_ind, |
| 697 | far_left_right_col_ind, |
| 698 | join_left, |
| 699 | join_right, |
| 700 | )?; |
| 701 | |
| 702 | Ok(Some(JoinData { |
| 703 | projected_left_child: new_left, |
no test coverage detected
searching dependent graphs…