Skip to content

Commit

Permalink
add tests for similar looking snowflake syntax
Browse files Browse the repository at this point in the history
  • Loading branch information
jmhain committed May 27, 2024
1 parent b9ce75a commit 1dd4f33
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 1 deletion.
2 changes: 1 addition & 1 deletion tests/sqlparser_postgres.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2038,7 +2038,7 @@ fn parse_array_subscript() {
assert_eq!(expect, *subscript);
}

// pg_and_generic().verified_expr("schedule[:2][2:]");
pg_and_generic().verified_expr("schedule[:2][2:]");
}

#[test]
Expand Down
30 changes: 30 additions & 0 deletions tests/sqlparser_snowflake.rs
Original file line number Diff line number Diff line change
Expand Up @@ -344,6 +344,36 @@ fn parse_semi_structured_data_traversal() {
})],
select.projection
);

// a json access used as a key to another json access
assert_eq!(
snowflake().verified_expr("a[b:c]"),
Expr::JsonAccess {
value: Box::new(Expr::Identifier(Ident::new("a"))),
path: JsonPath {
path: vec![JsonPathElem::Bracket {
key: Expr::JsonAccess {
value: Box::new(Expr::Identifier(Ident::new("b"))),
path: JsonPath {
path: vec![JsonPathElem::Dot {
key: "c".to_owned(),
quoted: false
}]
}
}
}]
}
}
);

// unquoted object keys cannot start with a digit
assert_eq!(
snowflake()
.parse_sql_statements("SELECT a:42")
.unwrap_err()
.to_string(),
"sql parser error: Expected variant object key name, found: 42"
);
}

#[test]
Expand Down

0 comments on commit 1dd4f33

Please sign in to comment.