Skip to content

Commit 4cf2323

Browse files
committed
Snowflake: GRANT CREATE SCHEMA, GRANT .. ON ALL FUNCTIONS IN SCHEMA
1 parent 4921846 commit 4cf2323

File tree

3 files changed

+24
-0
lines changed

3 files changed

+24
-0
lines changed

src/ast/mod.rs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6765,6 +6765,7 @@ pub enum ActionCreateObjectType {
67656765
OrganiationListing,
67666766
ReplicationGroup,
67676767
Role,
6768+
Schema,
67686769
Share,
67696770
User,
67706771
Warehouse,
@@ -6786,6 +6787,7 @@ impl fmt::Display for ActionCreateObjectType {
67866787
ActionCreateObjectType::OrganiationListing => write!(f, "ORGANIZATION LISTING"),
67876788
ActionCreateObjectType::ReplicationGroup => write!(f, "REPLICATION GROUP"),
67886789
ActionCreateObjectType::Role => write!(f, "ROLE"),
6790+
ActionCreateObjectType::Schema => write!(f, "SCHEMA"),
67896791
ActionCreateObjectType::Share => write!(f, "SHARE"),
67906792
ActionCreateObjectType::User => write!(f, "USER"),
67916793
ActionCreateObjectType::Warehouse => write!(f, "WAREHOUSE"),
@@ -7023,6 +7025,8 @@ pub enum GrantObjects {
70237025
AllMaterializedViewsInSchema { schemas: Vec<ObjectName> },
70247026
/// Grant privileges on `ALL EXTERNAL TABLES IN SCHEMA <schema_name> [, ...]`
70257027
AllExternalTablesInSchema { schemas: Vec<ObjectName> },
7028+
/// Grant privileges on `ALL FUNCTIONS IN SCHEMA <schema_name> [, ...]`
7029+
AllFunctionsInSchema { schemas: Vec<ObjectName> },
70267030
/// Grant privileges on `FUTURE SCHEMAS IN DATABASE <database_name> [, ...]`
70277031
FutureSchemasInDatabase { databases: Vec<ObjectName> },
70287032
/// Grant privileges on `FUTURE TABLES IN SCHEMA <schema_name> [, ...]`
@@ -7143,6 +7147,13 @@ impl fmt::Display for GrantObjects {
71437147
display_comma_separated(schemas)
71447148
)
71457149
}
7150+
GrantObjects::AllFunctionsInSchema { schemas } => {
7151+
write!(
7152+
f,
7153+
"ALL FUNCTIONS IN SCHEMA {}",
7154+
display_comma_separated(schemas)
7155+
)
7156+
}
71467157
GrantObjects::FutureSchemasInDatabase { databases } => {
71477158
write!(
71487159
f,

src/parser/mod.rs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14070,6 +14070,15 @@ impl<'a> Parser<'a> {
1407014070
Some(GrantObjects::AllMaterializedViewsInSchema {
1407114071
schemas: self.parse_comma_separated(|p| p.parse_object_name(false))?,
1407214072
})
14073+
} else if self.parse_keywords(&[
14074+
Keyword::ALL,
14075+
Keyword::FUNCTIONS,
14076+
Keyword::IN,
14077+
Keyword::SCHEMA,
14078+
]) {
14079+
Some(GrantObjects::AllFunctionsInSchema {
14080+
schemas: self.parse_comma_separated(|p| p.parse_object_name(false))?,
14081+
})
1407314082
} else if self.parse_keywords(&[
1407414083
Keyword::FUTURE,
1407514084
Keyword::SCHEMAS,
@@ -14376,6 +14385,8 @@ impl<'a> Parser<'a> {
1437614385
Some(ActionCreateObjectType::Integration)
1437714386
} else if self.parse_keyword(Keyword::ROLE) {
1437814387
Some(ActionCreateObjectType::Role)
14388+
} else if self.parse_keyword(Keyword::SCHEMA) {
14389+
Some(ActionCreateObjectType::Schema)
1437914390
} else if self.parse_keyword(Keyword::SHARE) {
1438014391
Some(ActionCreateObjectType::Share)
1438114392
} else if self.parse_keyword(Keyword::USER) {

tests/sqlparser_common.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9498,6 +9498,7 @@ fn parse_grant() {
94989498
verified_stmt("GRANT SELECT ON ALL VIEWS IN SCHEMA db1.sc1 TO ROLE role1");
94999499
verified_stmt("GRANT SELECT ON ALL MATERIALIZED VIEWS IN SCHEMA db1.sc1 TO ROLE role1");
95009500
verified_stmt("GRANT SELECT ON ALL EXTERNAL TABLES IN SCHEMA db1.sc1 TO ROLE role1");
9501+
verified_stmt("GRANT USAGE ON ALL FUNCTIONS IN SCHEMA db1.sc1 TO ROLE role1");
95019502
verified_stmt("GRANT USAGE ON SCHEMA sc1 TO a:b");
95029503
verified_stmt("GRANT USAGE ON SCHEMA sc1 TO GROUP group1");
95039504
verified_stmt("GRANT OWNERSHIP ON ALL TABLES IN SCHEMA DEV_STAS_ROGOZHIN TO ROLE ANALYST");
@@ -9519,6 +9520,7 @@ fn parse_grant() {
95199520
verified_stmt("GRANT SELECT ON FUTURE SEQUENCES IN SCHEMA db1.sc1 TO ROLE role1");
95209521
verified_stmt("GRANT USAGE ON PROCEDURE db1.sc1.foo(INT) TO ROLE role1");
95219522
verified_stmt("GRANT USAGE ON FUNCTION db1.sc1.foo(INT) TO ROLE role1");
9523+
verified_stmt("GRANT CREATE SCHEMA ON DATABASE db1 TO ROLE role1");
95229524
}
95239525

95249526
#[test]

0 commit comments

Comments
 (0)