freshtonic commented on code in PR #1614:
URL: 
https://github.com/apache/datafusion-sqlparser-rs/pull/1614#discussion_r1895681055


##########
src/parser/mod.rs:
##########
@@ -9604,7 +9604,13 @@ impl<'a> Parser<'a> {
             top = Some(self.parse_top()?);
         }
 
-        let projection = self.parse_projection()?;
+        let projection = if dialect_of!(self is PostgreSqlDialect | 
GenericDialect)
+            && self.peek_keyword(Keyword::FROM)
+        {
+            vec![]
+        } else {
+            self.parse_projection()?
+        };

Review Comment:
   @iffyio I tried this and it's not straightforward without storing a value on 
the variant the identifies the dialect that was used to parse the AST.
   
   The following syntax would be problematic (to render, in `Display`):
   
   ```sql
   LOCK customers;
   ```
   
   In PG, the `TABLE` keyword is optional. In MySQL one of `TABLE` or `TABLES` 
is mandatory.
   
   The `Display` impl for `Statement`, in the `LockTable { .. }` match arm 
could potentially generate SQL that will not be parsable by Postgres if a 
`TABLES` keyword is emitted.
   
   Is there precedent for choosing how to render an AST fragment using a stored 
value to encode the dialect (or a proxy to the dialect) that was used to parse 
the AST?
   
   



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

Reply via email to