Skip to content

Commit 7558d35

Browse files
authored
Snowflake: Support IDENTIFIER for GRANT ROLE (#1957)
1 parent f49c30f commit 7558d35

File tree

4 files changed

+7
-2
lines changed

4 files changed

+7
-2
lines changed

src/ast/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6654,7 +6654,7 @@ pub enum Action {
66546654
Replicate,
66556655
ResolveAll,
66566656
Role {
6657-
role: Ident,
6657+
role: ObjectName,
66586658
},
66596659
Select {
66606660
columns: Option<Vec<Ident>>,

src/parser/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14357,7 +14357,7 @@ impl<'a> Parser<'a> {
1435714357
} else if self.parse_keyword(Keyword::REPLICATE) {
1435814358
Ok(Action::Replicate)
1435914359
} else if self.parse_keyword(Keyword::ROLE) {
14360-
let role = self.parse_identifier()?;
14360+
let role = self.parse_object_name(false)?;
1436114361
Ok(Action::Role { role })
1436214362
} else if self.parse_keyword(Keyword::SELECT) {
1436314363
Ok(Action::Select {

tests/sqlparser_common.rs

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

95549556
#[test]

tests/sqlparser_snowflake.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4500,4 +4500,7 @@ fn test_snowflake_identifier_function() {
45004500
.is_err(),
45014501
true
45024502
);
4503+
4504+
snowflake().verified_stmt("GRANT ROLE IDENTIFIER('AAA') TO USER IDENTIFIER('AAA')");
4505+
snowflake().verified_stmt("REVOKE ROLE IDENTIFIER('AAA') FROM USER IDENTIFIER('AAA')");
45034506
}

0 commit comments

Comments
 (0)