MCPcopy Create free account
hub / github.com/apache/datafusion / join_table_borders

Function join_table_borders

datafusion/physical-plan/src/projection.rs:909–935  ·  view source on GitHub ↗

Returns the last index before encountering a column coming from the right table when traveling through the projection from left to right, and the last index before encountering a column coming from the left table when traveling through the projection from right to left. If there is no column in the projection coming from the left side, it returns (-1, ...), if there is no column in the projection

(
    left_table_column_count: usize,
    projection_as_columns: &[(Column, String)],
)

Source from the content-addressed store, hash-verified

907/// If there is no column in the projection coming from the left side, it returns (-1, ...),
908/// if there is no column in the projection coming from the right side, it returns (..., projection length).
909pub fn join_table_borders(
910 left_table_column_count: usize,
911 projection_as_columns: &[(Column, String)],
912) -> (i32, i32) {
913 let far_right_left_col_ind = projection_as_columns
914 .iter()
915 .enumerate()
916 .take_while(|(_, (projection_column, _))| {
917 projection_column.index() < left_table_column_count
918 })
919 .last()
920 .map(|(index, _)| index as i32)
921 .unwrap_or(-1);
922
923 let far_left_right_col_ind = projection_as_columns
924 .iter()
925 .enumerate()
926 .rev()
927 .take_while(|(_, (projection_column, _))| {
928 projection_column.index() >= left_table_column_count
929 })
930 .last()
931 .map(|(index, _)| index as i32)
932 .unwrap_or(projection_as_columns.len() as i32);
933
934 (far_right_left_col_ind, far_left_right_col_ind)
935}
936
937/// Tries to update the equi-join `Column`'s of a join as if the input of
938/// the join was replaced by a projection.

Calls 5

lastMethod · 0.80
mapMethod · 0.45
iterMethod · 0.45
indexMethod · 0.45
lenMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…