alamb commented on code in PR #11636: URL: https://github.com/apache/datafusion/pull/11636#discussion_r1690124537
########## 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, + }), + ) => { Review Comment: Rather than returning "not implemented" it would be nice to just fall back to the existing code I think you could do it with a match guard like ```suggestion ) if left_name == right_name => { ``` ########## 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: I think this case can happen -- like `JOIN ON (t1.a = t2.b)` -- 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...@datafusion.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: github-unsubscr...@datafusion.apache.org For additional commands, e-mail: github-h...@datafusion.apache.org