osipovartem commented on code in PR #2489:
URL:
https://github.com/apache/datafusion-sqlparser-rs/pull/2489#discussion_r4004746324
##########
tests/sqlparser_snowflake.rs:
##########
@@ -4912,3 +4912,48 @@ 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_and_generic().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);
+
+ for sql in [
+ "CREATE TABLE t (o OBJECT(VARCHAR))",
+ "CREATE TABLE t (o OBJECT(city VARCHAR NULL))",
+ "CREATE TABLE t (o OBJECT(city VARCHAR)",
+ ] {
+ assert!(snowflake().parse_sql_statements(sql).is_err(), "{sql}");
+ }
+}
+
+#[test]
+fn test_plain_object_type() {
Review Comment:
Done. I folded the plain `OBJECT` assertion into
`test_structured_object_type` and removed the separate test case. The targeted
Snowflake parser test passes locally.
--
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]