LucaCappelletti94 commented on code in PR #2525:
URL: 
https://github.com/apache/datafusion-sqlparser-rs/pull/2525#discussion_r4098522744


##########
src/ast/query.rs:
##########
@@ -2224,11 +2228,15 @@ impl fmt::Display for TableFactor {
                 json_path,
                 sample,
                 index_hints,
+                has_trailing_asterisk,
             } => {
                 name.fmt(f)?;
                 if let Some(json_path) = json_path {
                     json_path.fmt(f)?;
                 }
+                if *has_trailing_asterisk {
+                    write!(f, "*")?;
+                }

Review Comment:
   You should render the `*` before `json_path`, matching the parse order. On 
Snowflake and Redshift (`supports_partiql`), `SELECT * FROM t*[0]` renders as 
`SELECT * FROM t[0]*`, which fails to parse back with `Expected: end of 
statement, found: *`.
   
   ```suggestion
                   if *has_trailing_asterisk {
                       write!(f, "*")?;
                   }
                   if let Some(json_path) = json_path {
                       json_path.fmt(f)?;
                   }
   ```



##########
src/parser/mod.rs:
##########
@@ -16720,6 +16720,10 @@ impl<'a> Parser<'a> {
         } else {
             let name = self.parse_object_name(true)?;
 
+            // Postgres/Snowflake: `FROM tab*` explicitly includes descendant 
tables.
+            // https://www.postgresql.org/docs/current/sql-select.html#SQL-FROM
+            let has_trailing_asterisk = self.consume_token(&Token::Mul);

Review Comment:
   You could drop this comment. Snowflake's `FROM` grammar has no `tab*` form, 
and the `has_trailing_asterisk` field doc already links the Postgres reference.
   
   ```suggestion
               let has_trailing_asterisk = self.consume_token(&Token::Mul);
   ```



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