alamb commented on code in PR #10803:
URL: https://github.com/apache/datafusion/pull/10803#discussion_r1628085176


##########
datafusion/sql/tests/cases/plan_to_sql.rs:
##########
@@ -78,6 +78,11 @@ fn roundtrip_expr() {
 #[test]
 fn roundtrip_statement() -> Result<()> {
     let tests: Vec<&str> = vec![
+            "select 1;",

Review Comment:
   ❤️ 



##########
datafusion/sql/src/unparser/ast.rs:
##########
@@ -367,6 +367,11 @@ impl RelationBuilder {
         new.relation = Option::Some(TableFactorBuilder::Derived(value));
         new
     }
+    pub fn empty(&mut self) -> &mut Self {
+        let new = self;
+        new.relation = Some(TableFactorBuilder::Empty);
+        new

Review Comment:
   I think you could also do this (which is more concise)
   
   ```suggestion
           self.relation = Some(TableFactorBuilder::Empty);
           new
   ```
   
   Though I see it follows the same pattern as the code above so if we are 
going to change any of the we should change them all



##########
datafusion/sql/src/unparser/plan.rs:
##########
@@ -389,7 +389,10 @@ impl Unparser<'_> {
                 )?;
 
                 let ast_join = ast::Join {

Review Comment:
   This is totally fine, but I figured I would point out another way to express 
this logic that you might prefer in future PRs
   
   Instead of 
   
   ```rust
      let ast_join = ast::Join {
                       relation: match right_relation.build()? {
                           Some(relation) => relation,
                           None => return internal_err!("Failed to build right 
relation"),
                       },
                       join_operator: self
                           .join_operator_to_sql(join.join_type, 
join_constraint),
                   };
   ```
   
   You can do something like this with a `let .. else` to match or return
   
   ```rust
      let Some(relation) = match right_relation.build()? else {
       return internal_err!("Failed to build right relation"),
      };
   
      let ast_join = ast::Join {
                       relation,
                       join_operator: self
                           .join_operator_to_sql(join.join_type, 
join_constraint),
                   };
   ```



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