seddonm1 commented on a change in pull request #797: URL: https://github.com/apache/arrow-datafusion/pull/797#discussion_r682103000
########## File path: datafusion/src/logical_plan/builder.rs ########## @@ -287,16 +287,125 @@ impl LogicalPlanBuilder { .into_iter() .zip(join_keys.1.into_iter()) .map(|(l, r)| { - let mut swap = false; let l = l.into(); - let left_key = l.clone().normalize(&self.plan).or_else(|_| { - swap = true; - l.normalize(right) - }); - if swap { - (r.into().normalize(&self.plan), left_key) - } else { - (left_key, r.into().normalize(right)) + let r = r.into(); + let lr = l.relation.clone(); + let rr = r.relation.clone(); + + match (lr, rr) { + (Some(lr), Some(rr)) => { + let l_is_left = + self.plan.all_schemas().iter().any(|schema| { + schema.fields().iter().any(|field| { + field.qualifier().unwrap() == &lr Review comment: Ok. Thanks. Let me go through this more carefully. -- 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