mingmwang commented on code in PR #4866:
URL: https://github.com/apache/arrow-datafusion/pull/4866#discussion_r1071014644
##########
datafusion/optimizer/src/eliminate_cross_join.rs:
##########
@@ -176,159 +178,138 @@ fn flatten_join_inputs(
fn find_inner_join(
left_input: &LogicalPlan,
rights: &mut Vec<LogicalPlan>,
- possible_join_keys: &mut Vec<(Expr, Expr)>,
- all_join_keys: &mut HashSet<(Expr, Expr)>,
+ possible_join_predicates: &mut Vec<Expr>,
) -> Result<LogicalPlan> {
+ let mut candidate_right_input: Option<(usize, Vec<Expr>)> = None;
for (i, right_input) in rights.iter().enumerate() {
- let mut join_keys = vec![];
-
- for (l, r) in &mut *possible_join_keys {
- let key_pair = find_valid_equijoin_key_pair(
- l,
- r,
- left_input.schema().clone(),
- right_input.schema().clone(),
- )?;
+ let predicate_schemas =
+ [left_input.schema().clone(), right_input.schema().clone()];
+
+ // equijoin_flag indicct if join_predicates contains equijoin expr.
+ let (join_predicates, equijoin_flag): (Vec<Expr>, bool) =
+ possible_join_predicates.iter().try_fold(
+ (Vec::<Expr>::new(), false),
+ |(mut join_filters, mut equijoin_flag), expr| {
+ let is_join_filter =
+ is_valid_join_predicate(expr, &predicate_schemas)?;
+ if is_join_filter {
+ join_filters.push(expr.clone());
+ }
Review Comment:
I think the `try_fold` result is not correct, `t1.a > 1` should not be
treated as join filters(Inner join/Cross join cases).
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]