finchxxia commented on code in PR #2403:
URL: 
https://github.com/apache/datafusion-sqlparser-rs/pull/2403#discussion_r3717373412


##########
src/parser/mod.rs:
##########
@@ -18404,7 +18404,9 @@ impl<'a> Parser<'a> {
             let table = self.parse_keyword(Keyword::TABLE);
             let table_object = self.parse_table_object()?;
 
+            // `BY NAME` is an INSERT clause, not a table alias.
             let table_alias = if self.dialect.supports_insert_table_alias()
+                && !self.peek_keywords(&[Keyword::BY, Keyword::NAME])

Review Comment:
   @iffyio I see. But in postgresQL dialect,  if we don't add keywords `BY 
NAME`, `BY` would be recognized as a table alias.
   
   So I think that would be clearer.
   ```
    let mut by_name = self.peek_keywords(&[Keyword::BY, Keyword::NAME]);
    let table_alias = if self.dialect.supports_insert_table_alias()
       && !by_name
       && !self.peek_sub_query()
       && self
           .peek_one_of_keywords(&[Keyword::DEFAULT, Keyword::VALUES])
           .is_none()
   
   // ...
   let partitioned = self.parse_insert_partition()?;
   by_name = self.parse_keywords(&[Keyword::BY, Keyword::NAME]) || by_name;
   ```



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