gruuya commented on code in PR #13182:
URL: https://github.com/apache/datafusion/pull/13182#discussion_r1825227285


##########
datafusion/expr/src/logical_plan/builder.rs:
##########
@@ -1214,15 +1214,37 @@ impl LogicalPlanBuilder {
             return plan_err!("left_keys and right_keys were not the same 
length");
         }
 
-        let join_key_pairs = equi_exprs
+        let exprs: Vec<(Expr, Expr)> = equi_exprs
             .0
             .into_iter()
-            .zip(equi_exprs.1.into_iter())
-            .map(|(l, r)| {
-                let left_key = l.into();
-                let right_key = r.into();
+            .zip(equi_exprs.1)
+            .map(|(l, r)| (l.into(), r.into()))
+            .collect();
+
+        let columns: Vec<_> = exprs
+            .iter()
+            .filter_map(|(l, r)| {
+                l.try_as_col().and_then(|left_col| {
+                    r.try_as_col().map(|right_col| (left_col, right_col))
+                })
+            })
+            .collect();
+        if columns.len() == exprs.len() {
+            // all expressions are columns
+            return self.join(

Review Comment:
   While this does solve the problem for the special case when expressions are 
all columns it doesn't solve the problem in general, right?
   
   I'm wondering whether just constraining the normalization for the left 
(right) expression(s) to the left (right) schema (without `using_cols`) is an 
adequate general approach
   ```rust
                   let normalized_left_key = 
normalize_col_with_schemas_and_ambiguity_check(
                       left_key,
                       &[&[self.plan.schema()]],
                       &[],
                   )?;
                   let normalized_right_key = 
normalize_col_with_schemas_and_ambiguity_check(
                       right_key,
                       &[&[right.schema()]],
                       &[],
                   )?;
   ```
   We'd lose the ability to resolve columns if the order of the passed expr 
keys is opposite to that of plans (and one can't mix cols due to the validation 
in `find_valid_equijoin_key_pair` anyway), but maybe that's ok since the docs 
explicitly state that `equi_exprs are "equijoin" predicates expressions on the 
existing and right inputs, respectively`.



-- 
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]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to