Skip to content

Commit 8ad8d95

Browse files
committed
Snowflake future grants
1 parent b9365b3 commit 8ad8d95

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
@@ -6885,6 +6885,12 @@ pub enum GrantObjects {
68856885
AllSequencesInSchema { schemas: Vec<ObjectName> },
68866886
/// Grant privileges on `ALL TABLES IN SCHEMA <schema_name> [, ...]`
68876887
AllTablesInSchema { schemas: Vec<ObjectName> },
6888+
/// Grant privileges on `FUTURE SCHEMAS IN DATABASE <database_name> [, ...]`
6889+
FutureSchemasInDatabase { databases: Vec<ObjectName> },
6890+
/// Grant privileges on `FUTURE TABLES IN SCHEMA <schema_name> [, ...]`
6891+
FutureTablesInSchema { schemas: Vec<ObjectName> },
6892+
/// Grant privileges on `FUTURE VIEWS IN SCHEMA <schema_name> [, ...]`
6893+
FutureViewsInSchema { schemas: Vec<ObjectName> },
68886894
/// Grant privileges on specific databases
68896895
Databases(Vec<ObjectName>),
68906896
/// Grant privileges on specific schemas
@@ -6953,6 +6959,27 @@ impl fmt::Display for GrantObjects {
69536959
display_comma_separated(schemas)
69546960
)
69556961
}
6962+
GrantObjects::FutureSchemasInDatabase { databases } => {
6963+
write!(
6964+
f,
6965+
"FUTURE SCHEMAS IN DATABASE {}",
6966+
display_comma_separated(databases)
6967+
)
6968+
}
6969+
GrantObjects::FutureTablesInSchema { schemas } => {
6970+
write!(
6971+
f,
6972+
"FUTURE TABLES IN SCHEMA {}",
6973+
display_comma_separated(schemas)
6974+
)
6975+
}
6976+
GrantObjects::FutureViewsInSchema { schemas } => {
6977+
write!(
6978+
f,
6979+
"FUTURE VIEWS IN SCHEMA {}",
6980+
display_comma_separated(schemas)
6981+
)
6982+
}
69566983
GrantObjects::ResourceMonitors(objects) => {
69576984
write!(f, "RESOURCE MONITOR {}", display_comma_separated(objects))
69586985
}

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
@@ -13683,6 +13683,33 @@ impl<'a> Parser<'a> {
1368313683
Some(GrantObjects::AllTablesInSchema {
1368413684
schemas: self.parse_comma_separated(|p| p.parse_object_name(false))?,
1368513685
})
13686+
} else if self.parse_keywords(&[
13687+
Keyword::FUTURE,
13688+
Keyword::SCHEMAS,
13689+
Keyword::IN,
13690+
Keyword::DATABASE,
13691+
]) {
13692+
Some(GrantObjects::FutureSchemasInDatabase {
13693+
databases: self.parse_comma_separated(|p| p.parse_object_name(false))?,
13694+
})
13695+
} else if self.parse_keywords(&[
13696+
Keyword::FUTURE,
13697+
Keyword::TABLES,
13698+
Keyword::IN,
13699+
Keyword::SCHEMA,
13700+
]) {
13701+
Some(GrantObjects::FutureTablesInSchema {
13702+
schemas: self.parse_comma_separated(|p| p.parse_object_name(false))?,
13703+
})
13704+
} else if self.parse_keywords(&[
13705+
Keyword::FUTURE,
13706+
Keyword::VIEWS,
13707+
Keyword::IN,
13708+
Keyword::SCHEMA,
13709+
]) {
13710+
Some(GrantObjects::FutureViewsInSchema {
13711+
schemas: self.parse_comma_separated(|p| p.parse_object_name(false))?,
13712+
})
1368613713
} else if self.parse_keywords(&[
1368713714
Keyword::ALL,
1368813715
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)