Support subquery as function arg w/o parens in Snowflake dialect (#996)

This commit is contained in:
Joey Hain 2023-10-23 14:50:45 -07:00 committed by GitHub
parent 5c10668dbb
commit 56f24ce236
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 39 additions and 1 deletions

View file

@ -1065,3 +1065,23 @@ fn test_snowflake_trim() {
snowflake().parse_sql_statements(error_sql).unwrap_err()
);
}
#[test]
fn parse_subquery_function_argument() {
// Snowflake allows passing an unparenthesized subquery as the single
// argument to a function.
snowflake().one_statement_parses_to(
"SELECT parse_json(SELECT '{}')",
"SELECT parse_json((SELECT '{}'))",
);
// Subqueries that begin with WITH work too.
snowflake().one_statement_parses_to(
"SELECT parse_json(WITH q AS (SELECT '{}' AS foo) SELECT foo FROM q)",
"SELECT parse_json((WITH q AS (SELECT '{}' AS foo) SELECT foo FROM q))",
);
// Commas are parsed as part of the subquery, not additional arguments to
// the function.
snowflake().one_statement_parses_to("SELECT func(SELECT 1, 2)", "SELECT func((SELECT 1, 2))");
}