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


##########
tests/sqlparser_snowflake.rs:
##########
@@ -4912,3 +4912,38 @@ 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 test_structured_object_type() {
+    snowflake().verified_stmt(
+        "SELECT payload::OBJECT(address OBJECT(city VARCHAR NOT NULL), zip 
NUMBER) FROM t",
+    );
+
+    let select = snowflake().verified_only_select(
+        "SELECT CAST(payload AS OBJECT(city VARCHAR, zip NUMBER NOT NULL)) 
FROM t",
+    );
+    let Expr::Cast { data_type, .. } = 
expr_from_projection(only(&select.projection)) else {
+        unreachable!();
+    };
+    let DataType::Object(fields) = data_type else {
+        unreachable!();
+    };
+    assert_eq!(fields.len(), 2);
+    assert_eq!(fields[0].name, Ident::new("city"));
+    assert!(fields[0].options.is_empty());
+    assert_eq!(fields[1].name, Ident::new("zip"));
+    assert_eq!(fields[1].options.len(), 1);
+    assert_eq!(fields[1].options[0].option, ColumnOption::NotNull);
+
+    snowflake().verified_stmt("CREATE TABLE t (o OBJECT)");
+}
+
+#[test]
+fn test_structured_object_type_errors() {

Review Comment:
   Done in ef16bd9d: merged the malformed-input assertions into 
test_structured_object_type. The focused Snowflake suite (165 tests) and cargo 
test --all-targets both pass locally.



##########
src/dialect/mod.rs:
##########
@@ -1083,6 +1083,16 @@ pub trait Dialect: Debug + Any {
         false
     }
 
+    /// Returns true if this dialect supports structured `OBJECT` types.
+    ///
+    /// Example:
+    /// ```sql
+    /// CREATE TABLE t (o OBJECT(city VARCHAR, zip NUMBER NOT NULL));
+    /// ```
+    fn supports_structured_object_type(&self) -> bool {
+        false
+    }

Review Comment:
   Updated in ef16bd9d: removed the dialect method and now parse structured 
OBJECT whenever OBJECT is followed by a parenthesized field list. The existing 
plain OBJECT fallback remains unchanged and is covered for both Snowflake and 
Generic dialects.



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