iffyio commented on code in PR #2359:
URL: 
https://github.com/apache/datafusion-sqlparser-rs/pull/2359#discussion_r3841406989


##########
tests/sqlparser_snowflake.rs:
##########
@@ -4912,3 +4912,21 @@ fn test_select_dollar_column_from_stage() {
     // With table function args, without alias
     snowflake().verified_stmt("SELECT $1, $2 FROM @mystage1(file_format => 
'myformat')");
 }
+
+#[test]
+fn parse_nested_object() {
+    // nested OBJECT with a single field
+    snowflake().verified_stmt("SELECT 
TRY_CAST(PARSE_JSON('{\"obj_field\":{\"field\":\"value\",}}') AS 
OBJECT(obj_field OBJECT(field VARCHAR)))");

Review Comment:
   heads up after switching to dialect method, these tests can use 
`all_dialects_where(|d| d.supportsxxx())` to select the dialect instead of 
hardcoding snowflake only



##########
src/parser/mod.rs:
##########
@@ -3657,6 +3657,32 @@ impl<'a> Parser<'a> {
     /// ```
     ///
     /// [1]: https://duckdb.org/docs/sql/data_types/union.html
+    fn parse_object_data_type(&mut self) -> Result<DataType, ParserError> {

Review Comment:
   hmm this diff looks a bit off,does the comment above apply to this new 
function? it looks like it was rather meant for parse_union_type_def



##########
src/parser/mod.rs:
##########
@@ -13036,6 +13036,31 @@ impl<'a> Parser<'a> {
                     let fields = self.parse_union_type_def()?;
                     Ok(DataType::Union(fields))
                 }
+                Keyword::OBJECT if dialect_is!(dialect is SnowflakeDialect | 
GenericDialect) => {

Review Comment:
   ah so I meant to use instead a `self.dialect.supportsxxx()` style method - 
that's 
[preferred](https://github.com/SatoriCyber/datafusion-sqlparser-rs/blob/e8e783abd2767871b743412333dc317221efd777/src/dialect/mod.rs#L146-L147)
 over the dialect_is macro



##########
src/ast/data_type.rs:
##########
@@ -465,6 +465,13 @@ pub enum DataType {
     ///
     /// [DuckDB]: https://duckdb.org/docs/sql/data_types/union.html
     Union(Vec<UnionField>),
+    /// Object type, see [Snowflake].

Review Comment:
   ```suggestion
       /// Object type.
   ```



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