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


##########
src/parser/mod.rs:
##########
@@ -5199,12 +5199,22 @@ impl<'a> Parser<'a> {
 
         // parse: [ argname ] argtype
         let mut name = None;
+        let next_token = self.peek_token();
         let mut data_type = self.parse_data_type()?;
-        if let DataType::Custom(n, _) = &data_type {
-            // the first token is actually a name
-            match n.0[0].clone() {
-                ObjectNamePart::Identifier(ident) => name = Some(ident),
-            }
+
+        // It may appear that the first token can be converted into a known
+        // type, but this could also be a collision as some types are only
+        // present in some dialects and therefore some type reserved keywords
+        // may be freely used as argument names in other dialects.
+
+        // To check whether the first token is a name or a type, we need to
+        // peek the next token, which if it is another type keyword, then the
+        // first token is a name and not a type in itself.
+        let potential_tokens = [Token::Eq, Token::RParen, Token::Comma];
+        if !self.peek_keyword(Keyword::DEFAULT)
+            && !potential_tokens.contains(&self.peek_token().token)
+        {
+            name = Some(Ident::new(next_token.to_string()));

Review Comment:
   The code you proposed does not work as `Int2` (or any analogous such type) 
does not fall in `if let DataType::Custom(n, _) = &data_type {`, but other 
variants. I am trying to update my own version using `maybe_parse` instead of 
the keywords check.



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