lr_is_preserved

Function lr_is_preserved 

Source
pub(crate) fn lr_is_preserved(join_type: JoinType) -> (bool, bool)
Expand description

For a given JOIN type, determine whether each input of the join is preserved for post-join (WHERE clause) filters.

It is only correct to push filters below a join for preserved inputs.

§Return Value

A tuple of booleans - (left_preserved, right_preserved).

§“Preserved” input definition

We say a join side is preserved if the join returns all or a subset of the rows from the relevant side, such that each row of the output table directly maps to a row of the preserved input table. If a table is not preserved, it can provide extra null rows. That is, there may be rows in the output table that don’t directly map to a row in the input table.

For example:

  • In an inner join, both sides are preserved, because each row of the output maps directly to a row from each side.

  • In a left join, the left side is preserved (we can push predicates) but the right is not, because there may be rows in the output that don’t directly map to a row in the right input (due to nulls filling where there is no match on the right).