andygrove commented on code in PR #2702: URL: https://github.com/apache/arrow-datafusion/pull/2702#discussion_r890325614
########## datafusion/expr/src/logical_plan/builder.rs: ########## @@ -605,17 +606,52 @@ impl LogicalPlanBuilder { let on: Vec<(_, _)> = left_keys.into_iter().zip(right_keys.into_iter()).collect(); let join_schema = build_join_schema(self.plan.schema(), right.schema(), &join_type)?; - - Ok(Self::from(LogicalPlan::Join(Join { - left: Arc::new(self.plan.clone()), - right: Arc::new(right.clone()), - on, - filter: None, - join_type, - join_constraint: JoinConstraint::Using, - schema: DFSchemaRef::new(join_schema), - null_equals_null: false, - }))) + let mut join_on: Vec<(Column, Column)> = vec![]; + let mut filters: Option<Expr> = None; + for (l, r) in &on { + if self.plan.schema().field_from_column(l).is_ok() + && right.schema().field_from_column(r).is_ok() + && can_hash(self.plan.schema().field_from_column(l).unwrap().data_type()) + { + join_on.push((l.clone(), r.clone())); + } else if self.plan.schema().field_from_column(r).is_ok() + && right.schema().field_from_column(l).is_ok() + && can_hash(self.plan.schema().field_from_column(r).unwrap().data_type()) + { + join_on.push((r.clone(), l.clone())); + } else { + let expr = Expr::BinaryExpr { + left: Box::new(Expr::Column(l.clone())), + op: Operator::Eq, + right: Box::new(Expr::Column(r.clone())), + }; Review Comment: nit: we can use `binary_expr` helper here for more concise code ``` let expr = binary_expr( Expr::Column(l.clone()), Operator::Eq, Expr::Column(r.clone()), ); ``` -- 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: github-unsubscr...@arrow.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org