Skip to content

Commit 787c5cc

Browse files
yoavcloudayman-sigma
authored andcommitted
Snowflake: Add support for future grants (apache#1906)
1 parent 4792951 commit 787c5cc

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
@@ -6949,6 +6949,12 @@ pub enum GrantObjects {
69496949
AllSequencesInSchema { schemas: Vec<ObjectName> },
69506950
/// Grant privileges on `ALL TABLES IN SCHEMA <schema_name> [, ...]`
69516951
AllTablesInSchema { schemas: Vec<ObjectName> },
6952+
/// Grant privileges on `FUTURE SCHEMAS IN DATABASE <database_name> [, ...]`
6953+
FutureSchemasInDatabase { databases: Vec<ObjectName> },
6954+
/// Grant privileges on `FUTURE TABLES IN SCHEMA <schema_name> [, ...]`
6955+
FutureTablesInSchema { schemas: Vec<ObjectName> },
6956+
/// Grant privileges on `FUTURE VIEWS IN SCHEMA <schema_name> [, ...]`
6957+
FutureViewsInSchema { schemas: Vec<ObjectName> },
69526958
/// Grant privileges on specific databases
69536959
Databases(Vec<ObjectName>),
69546960
/// Grant privileges on specific schemas
@@ -7017,6 +7023,27 @@ impl fmt::Display for GrantObjects {
70177023
display_comma_separated(schemas)
70187024
)
70197025
}
7026+
GrantObjects::FutureSchemasInDatabase { databases } => {
7027+
write!(
7028+
f,
7029+
"FUTURE SCHEMAS IN DATABASE {}",
7030+
display_comma_separated(databases)
7031+
)
7032+
}
7033+
GrantObjects::FutureTablesInSchema { schemas } => {
7034+
write!(
7035+
f,
7036+
"FUTURE TABLES IN SCHEMA {}",
7037+
display_comma_separated(schemas)
7038+
)
7039+
}
7040+
GrantObjects::FutureViewsInSchema { schemas } => {
7041+
write!(
7042+
f,
7043+
"FUTURE VIEWS IN SCHEMA {}",
7044+
display_comma_separated(schemas)
7045+
)
7046+
}
70207047
GrantObjects::ResourceMonitors(objects) => {
70217048
write!(f, "RESOURCE MONITOR {}", display_comma_separated(objects))
70227049
}

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
@@ -13723,6 +13723,33 @@ impl<'a> Parser<'a> {
1372313723
Some(GrantObjects::AllTablesInSchema {
1372413724
schemas: self.parse_comma_separated(|p| p.parse_object_name(false))?,
1372513725
})
13726+
} else if self.parse_keywords(&[
13727+
Keyword::FUTURE,
13728+
Keyword::SCHEMAS,
13729+
Keyword::IN,
13730+
Keyword::DATABASE,
13731+
]) {
13732+
Some(GrantObjects::FutureSchemasInDatabase {
13733+
databases: self.parse_comma_separated(|p| p.parse_object_name(false))?,
13734+
})
13735+
} else if self.parse_keywords(&[
13736+
Keyword::FUTURE,
13737+
Keyword::TABLES,
13738+
Keyword::IN,
13739+
Keyword::SCHEMA,
13740+
]) {
13741+
Some(GrantObjects::FutureTablesInSchema {
13742+
schemas: self.parse_comma_separated(|p| p.parse_object_name(false))?,
13743+
})
13744+
} else if self.parse_keywords(&[
13745+
Keyword::FUTURE,
13746+
Keyword::VIEWS,
13747+
Keyword::IN,
13748+
Keyword::SCHEMA,
13749+
]) {
13750+
Some(GrantObjects::FutureViewsInSchema {
13751+
schemas: self.parse_comma_separated(|p| p.parse_object_name(false))?,
13752+
})
1372613753
} else if self.parse_keywords(&[
1372713754
Keyword::ALL,
1372813755
Keyword::SEQUENCES,

tests/sqlparser_common.rs

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

93959397
#[test]

0 commit comments

Comments
 (0)