risingwave_frontend::optimizer::plan_node::logical_join

Function derive_predicate_from_eq_condition

source
fn derive_predicate_from_eq_condition(
    expr: &ExprImpl,
    eq_condition: &EqJoinPredicate,
    col_num: usize,
    expr_is_left: bool,
) -> Option<ExprImpl>
Expand description

We are trying to derive a predicate to apply to the other side of a join if all the InputRefs in the predicate are eq condition columns, and can hence be substituted with the corresponding eq condition columns of the other side.

Strategy:

  1. If the function is pure except for any InputRef (which may refer to impure computation), then we proceed. Else abort.
  2. Then, we collect InputRefs in the conjunction.
  3. If they are all columns in the given side of join eq condition, then we proceed. Else abort.
  4. We then rewrite the ExprImpl, by replacing InputRef column indices with the equivalent in the other side.

ยงArguments

Suppose we derive a predicate from the left side to be pushed to the right side.

  • expr: An expr from the left side.
  • col_num: The number of columns in the left side.