Skip to content

Commit c922bbe

Browse files
yoavcloudayman-sigma
authored andcommitted
Add support for USE SECONDARY ROLE (vs. ROLES) (apache#1637)
1 parent 733d8e9 commit c922bbe

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

src/parser/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10539,7 +10539,7 @@ impl<'a> Parser<'a> {
1053910539
}
1054010540

1054110541
fn parse_secondary_roles(&mut self) -> Result<Use, ParserError> {
10542-
self.expect_keyword_is(Keyword::ROLES)?;
10542+
self.expect_one_of_keywords(&[Keyword::ROLES, Keyword::ROLE])?;
1054310543
if self.parse_keyword(Keyword::NONE) {
1054410544
Ok(Use::SecondaryRoles(SecondaryRoles::None))
1054510545
} else if self.parse_keyword(Keyword::ALL) {

tests/sqlparser_snowflake.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2789,6 +2789,14 @@ fn parse_use() {
27892789
snowflake().verified_stmt("USE SECONDARY ROLES ALL");
27902790
snowflake().verified_stmt("USE SECONDARY ROLES NONE");
27912791
snowflake().verified_stmt("USE SECONDARY ROLES r1, r2, r3");
2792+
2793+
// The following is not documented by Snowflake but still works:
2794+
snowflake().one_statement_parses_to("USE SECONDARY ROLE ALL", "USE SECONDARY ROLES ALL");
2795+
snowflake().one_statement_parses_to("USE SECONDARY ROLE NONE", "USE SECONDARY ROLES NONE");
2796+
snowflake().one_statement_parses_to(
2797+
"USE SECONDARY ROLE r1, r2, r3",
2798+
"USE SECONDARY ROLES r1, r2, r3",
2799+
);
27922800
}
27932801

27942802
#[test]

0 commit comments

Comments
 (0)