Skip to content

Commit 371d532

Browse files
yoavcloudayman-sigma
authored andcommitted
Snowflake: Support IDENTIFIER for GRANT ROLE (apache#1957)
1 parent deb1d6a commit 371d532

4 files changed

Lines changed: 7 additions & 2 deletions

File tree

src/ast/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6683,7 +6683,7 @@ pub enum Action {
66836683
Replicate,
66846684
ResolveAll,
66856685
Role {
6686-
role: Ident,
6686+
role: ObjectName,
66876687
},
66886688
Select {
66896689
columns: Option<Vec<Ident>>,

src/parser/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14389,7 +14389,7 @@ impl<'a> Parser<'a> {
1438914389
} else if self.parse_keyword(Keyword::REPLICATE) {
1439014390
Ok(Action::Replicate)
1439114391
} else if self.parse_keyword(Keyword::ROLE) {
14392-
let role = self.parse_identifier()?;
14392+
let role = self.parse_object_name(false)?;
1439314393
Ok(Action::Role { role })
1439414394
} else if self.parse_keyword(Keyword::SELECT) {
1439514395
Ok(Action::Select {

tests/sqlparser_common.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9550,6 +9550,8 @@ fn parse_grant() {
95509550
verified_stmt("GRANT SELECT ON FUTURE SEQUENCES IN SCHEMA db1.sc1 TO ROLE role1");
95519551
verified_stmt("GRANT USAGE ON PROCEDURE db1.sc1.foo(INT) TO ROLE role1");
95529552
verified_stmt("GRANT USAGE ON FUNCTION db1.sc1.foo(INT) TO ROLE role1");
9553+
verified_stmt("GRANT ROLE role1 TO ROLE role2");
9554+
verified_stmt("GRANT ROLE role1 TO USER user");
95539555
}
95549556

95559557
#[test]

tests/sqlparser_snowflake.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4519,4 +4519,7 @@ fn test_snowflake_identifier_function() {
45194519
.is_err(),
45204520
true
45214521
);
4522+
4523+
snowflake().verified_stmt("GRANT ROLE IDENTIFIER('AAA') TO USER IDENTIFIER('AAA')");
4524+
snowflake().verified_stmt("REVOKE ROLE IDENTIFIER('AAA') FROM USER IDENTIFIER('AAA')");
45224525
}

0 commit comments

Comments
 (0)