Skip to content

Commit 6c38cdc

Browse files
authored
Snowflake: Add support for future grants (apache#1906)
1 parent 5f2b5fe commit 6c38cdc

File tree

4 files changed

+58
-1
lines changed

4 files changed

+58
-1
lines changed

src/ast/mod.rs

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6920,6 +6920,12 @@ pub enum GrantObjects {
69206920
AllSequencesInSchema { schemas: Vec<ObjectName> },
69216921
/// Grant privileges on `ALL TABLES IN SCHEMA <schema_name> [, ...]`
69226922
AllTablesInSchema { schemas: Vec<ObjectName> },
6923+
/// Grant privileges on `FUTURE SCHEMAS IN DATABASE <database_name> [, ...]`
6924+
FutureSchemasInDatabase { databases: Vec<ObjectName> },
6925+
/// Grant privileges on `FUTURE TABLES IN SCHEMA <schema_name> [, ...]`
6926+
FutureTablesInSchema { schemas: Vec<ObjectName> },
6927+
/// Grant privileges on `FUTURE VIEWS IN SCHEMA <schema_name> [, ...]`
6928+
FutureViewsInSchema { schemas: Vec<ObjectName> },
69236929
/// Grant privileges on specific databases
69246930
Databases(Vec<ObjectName>),
69256931
/// Grant privileges on specific schemas
@@ -6988,6 +6994,27 @@ impl fmt::Display for GrantObjects {
69886994
display_comma_separated(schemas)
69896995
)
69906996
}
6997+
GrantObjects::FutureSchemasInDatabase { databases } => {
6998+
write!(
6999+
f,
7000+
"FUTURE SCHEMAS IN DATABASE {}",
7001+
display_comma_separated(databases)
7002+
)
7003+
}
7004+
GrantObjects::FutureTablesInSchema { schemas } => {
7005+
write!(
7006+
f,
7007+
"FUTURE TABLES IN SCHEMA {}",
7008+
display_comma_separated(schemas)
7009+
)
7010+
}
7011+
GrantObjects::FutureViewsInSchema { schemas } => {
7012+
write!(
7013+
f,
7014+
"FUTURE VIEWS IN SCHEMA {}",
7015+
display_comma_separated(schemas)
7016+
)
7017+
}
69917018
GrantObjects::ResourceMonitors(objects) => {
69927019
write!(f, "RESOURCE MONITOR {}", display_comma_separated(objects))
69937020
}

src/keywords.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -395,6 +395,7 @@ define_keywords!(
395395
FUNCTION,
396396
FUNCTIONS,
397397
FUSION,
398+
FUTURE,
398399
GENERAL,
399400
GENERATE,
400401
GENERATED,

src/parser/mod.rs

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13691,6 +13691,33 @@ impl<'a> Parser<'a> {
1369113691
Some(GrantObjects::AllTablesInSchema {
1369213692
schemas: self.parse_comma_separated(|p| p.parse_object_name(false))?,
1369313693
})
13694+
} else if self.parse_keywords(&[
13695+
Keyword::FUTURE,
13696+
Keyword::SCHEMAS,
13697+
Keyword::IN,
13698+
Keyword::DATABASE,
13699+
]) {
13700+
Some(GrantObjects::FutureSchemasInDatabase {
13701+
databases: self.parse_comma_separated(|p| p.parse_object_name(false))?,
13702+
})
13703+
} else if self.parse_keywords(&[
13704+
Keyword::FUTURE,
13705+
Keyword::TABLES,
13706+
Keyword::IN,
13707+
Keyword::SCHEMA,
13708+
]) {
13709+
Some(GrantObjects::FutureTablesInSchema {
13710+
schemas: self.parse_comma_separated(|p| p.parse_object_name(false))?,
13711+
})
13712+
} else if self.parse_keywords(&[
13713+
Keyword::FUTURE,
13714+
Keyword::VIEWS,
13715+
Keyword::IN,
13716+
Keyword::SCHEMA,
13717+
]) {
13718+
Some(GrantObjects::FutureViewsInSchema {
13719+
schemas: self.parse_comma_separated(|p| p.parse_object_name(false))?,
13720+
})
1369413721
} else if self.parse_keywords(&[
1369513722
Keyword::ALL,
1369613723
Keyword::SEQUENCES,

tests/sqlparser_common.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9386,9 +9386,11 @@ fn parse_grant() {
93869386
verified_stmt("GRANT SELECT ON VIEW view1 TO ROLE role1");
93879387
verified_stmt("GRANT EXEC ON my_sp TO runner");
93889388
verified_stmt("GRANT UPDATE ON my_table TO updater_role AS dbo");
9389-
93909389
all_dialects_where(|d| d.identifier_quote_style("none") == Some('['))
93919390
.verified_stmt("GRANT SELECT ON [my_table] TO [public]");
9391+
verified_stmt("GRANT SELECT ON FUTURE SCHEMAS IN DATABASE db1 TO ROLE role1");
9392+
verified_stmt("GRANT SELECT ON FUTURE TABLES IN SCHEMA db1.sc1 TO ROLE role1");
9393+
verified_stmt("GRANT SELECT ON FUTURE VIEWS IN SCHEMA db1.sc1 TO ROLE role1");
93929394
}
93939395

93949396
#[test]

0 commit comments

Comments
 (0)