Skip to content

Commit 1dd4f33

Browse files
committed
add tests for similar looking snowflake syntax
1 parent b9ce75a commit 1dd4f33

File tree

2 files changed

+31
-1
lines changed

2 files changed

+31
-1
lines changed

tests/sqlparser_postgres.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2038,7 +2038,7 @@ fn parse_array_subscript() {
20382038
assert_eq!(expect, *subscript);
20392039
}
20402040

2041-
// pg_and_generic().verified_expr("schedule[:2][2:]");
2041+
pg_and_generic().verified_expr("schedule[:2][2:]");
20422042
}
20432043

20442044
#[test]

tests/sqlparser_snowflake.rs

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -344,6 +344,36 @@ fn parse_semi_structured_data_traversal() {
344344
})],
345345
select.projection
346346
);
347+
348+
// a json access used as a key to another json access
349+
assert_eq!(
350+
snowflake().verified_expr("a[b:c]"),
351+
Expr::JsonAccess {
352+
value: Box::new(Expr::Identifier(Ident::new("a"))),
353+
path: JsonPath {
354+
path: vec![JsonPathElem::Bracket {
355+
key: Expr::JsonAccess {
356+
value: Box::new(Expr::Identifier(Ident::new("b"))),
357+
path: JsonPath {
358+
path: vec![JsonPathElem::Dot {
359+
key: "c".to_owned(),
360+
quoted: false
361+
}]
362+
}
363+
}
364+
}]
365+
}
366+
}
367+
);
368+
369+
// unquoted object keys cannot start with a digit
370+
assert_eq!(
371+
snowflake()
372+
.parse_sql_statements("SELECT a:42")
373+
.unwrap_err()
374+
.to_string(),
375+
"sql parser error: Expected variant object key name, found: 42"
376+
);
347377
}
348378

349379
#[test]

0 commit comments

Comments
 (0)