split_eq_and_noneq_join_predicate

Function split_eq_and_noneq_join_predicate 

Source
fn split_eq_and_noneq_join_predicate(
    filter: Expr,
    left_schema: &DFSchema,
    right_schema: &DFSchema,
) -> Result<(Vec<(Expr, Expr)>, Option<Expr>)>
Expand description

Splits an ANDed filter expression into equijoin predicates and remaining filters. Returns all equijoin predicates and the remaining filters combined with AND.

ยงExample

For the expression a.id = b.id AND a.x > 10 AND b.x > b.id, this function will extract a.id = b.id as an equijoin predicate.

It first splits the ANDed sub-expressions:

  • expr1: a.id = b.id
  • expr2: a.x > 10
  • expr3: b.x > b.id

Then, it filters out the equijoin predicates and collects the non-equality expressions. The equijoin condition is:

  • It is an equality expression like lhs == rhs
  • All column references in lhs are from the left schema, and all in rhs are from the right schema

According to the above rule, expr1 is the equijoin predicate, while expr2 and expr3 are not. The function returns Ok([expr1], Some(expr2 AND expr3))