wackywendell commented on code in PR #11636:
URL: https://github.com/apache/datafusion/pull/11636#discussion_r1690203149


##########
datafusion/sql/src/unparser/plan.rs:
##########
@@ -582,9 +558,89 @@ impl Unparser<'_> {
         }
     }
 
+    /// Convert the components of a USING clause to the USING AST
+    fn join_using_to_sql(
+        &self,
+        join_conditions: &[(Expr, Expr)],
+    ) -> Result<ast::JoinConstraint> {
+        let mut idents = Vec::with_capacity(join_conditions.len());
+        for (left, right) in join_conditions {
+            match (left, right) {
+                (
+                    Expr::Column(Column {
+                        relation: _,
+                        name: left_name,
+                    }),
+                    Expr::Column(Column {
+                        relation: _,
+                        name: right_name,
+                    }),
+                ) => {
+                    if left_name != right_name {
+                        // USING is only valid when the column names are the
+                        // same, so they should never be different
+                        return not_impl_err!(
+                            "Unsupported USING with different column names"
+                        );

Review Comment:
   So I thought about this some more - these two cases should be impossible for 
a `LogicalPlan` made from SQL (you can't do `JOIN … USING (t1.a = t1.b)`, but 
could be created by a user directly creating a `LogicalPlan::Join(Join { … })`.
   
   Given that, fallback makes sense, and I'll add a comment to explain.
   
   



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