osipovartem commented on code in PR #2489:
URL: 
https://github.com/apache/datafusion-sqlparser-rs/pull/2489#discussion_r4103696405


##########
src/parser/mod.rs:
##########
@@ -3801,15 +3801,19 @@ impl<'a> Parser<'a> {
     /// ```
     ///
     /// [map]: https://clickhouse.com/docs/en/sql-reference/data-types/map
-    fn parse_click_house_map_def(&mut self) -> Result<(DataType, DataType), 
ParserError> {
+    fn parse_parenthesized_map_type_def(
+        &mut self,
+    ) -> Result<(DataType, DataType, bool), ParserError> {
         self.expect_keyword_is(Keyword::MAP)?;
         self.expect_token(&Token::LParen)?;
         let key_data_type = self.parse_data_type()?;
         self.expect_token(&Token::Comma)?;
         let value_data_type = self.parse_data_type()?;
+        let value_not_null = dialect_of!(self is SnowflakeDialect)
+            && self.parse_keywords(&[Keyword::NOT, Keyword::NULL]);

Review Comment:
   Added `supports_map_value_not_null()` and used it in the parser (67c962b6).



##########
src/parser/mod.rs:
##########
@@ -13216,13 +13241,20 @@ impl<'a> Parser<'a> {
                         MapBracketKind::AngleBrackets,
                     ))
                 }
-                Keyword::MAP if dialect_is!(dialect is ClickHouseDialect | 
GenericDialect) => {
+                Keyword::MAP if dialect_is!(dialect is ClickHouseDialect | 
GenericDialect | SnowflakeDialect) =>

Review Comment:
   Replaced the dialect checks with capability methods and derive the AST 
variant from `NOT NULL` (67c962b6).



##########
src/parser/mod.rs:
##########
@@ -13178,6 +13182,27 @@ impl<'a> Parser<'a> {
                         ))))
                     }
                 }
+                Keyword::OBJECT
+                    if self.peek_token_ref().token == Token::LParen
+                        && (dialect_is!(dialect is SnowflakeDialect)
+                            || !matches!(
+                                self.peek_nth_token_ref(1).token,
+                                Token::SingleQuotedString(_)
+                            )) =>
+                {
+                    if dialect_is!(dialect is SnowflakeDialect) {
+                        
Ok(DataType::Object(self.parse_structured_object_type_def()?))
+                    } else if let Some(fields) =
+                        self.maybe_parse(|parser| 
parser.parse_structured_object_type_def())?
+                    {
+                        Ok(DataType::Object(fields))
+                    } else {
+                        self.prev_token();
+                        let type_name = self.parse_object_name(false)?;
+                        let modifiers = 
self.parse_optional_type_modifiers()?.unwrap_or_default();
+                        Ok(DataType::Custom(type_name, modifiers))
+                    }
+                }

Review Comment:
   The structured-then-custom path now applies to every dialect (67c962b6).



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