mirror of
https://github.com/apache/datafusion-sqlparser-rs.git
synced 2025-07-08 01:15:00 +00:00
Snowflake: Add support for future grants (#1906)
Some checks are pending
license / Release Audit Tool (RAT) (push) Waiting to run
Rust / codestyle (push) Waiting to run
Rust / lint (push) Waiting to run
Rust / benchmark-lint (push) Waiting to run
Rust / compile (push) Waiting to run
Rust / docs (push) Waiting to run
Rust / compile-no-std (push) Waiting to run
Rust / test (beta) (push) Waiting to run
Rust / test (nightly) (push) Waiting to run
Rust / test (stable) (push) Waiting to run
Some checks are pending
license / Release Audit Tool (RAT) (push) Waiting to run
Rust / codestyle (push) Waiting to run
Rust / lint (push) Waiting to run
Rust / benchmark-lint (push) Waiting to run
Rust / compile (push) Waiting to run
Rust / docs (push) Waiting to run
Rust / compile-no-std (push) Waiting to run
Rust / test (beta) (push) Waiting to run
Rust / test (nightly) (push) Waiting to run
Rust / test (stable) (push) Waiting to run
This commit is contained in:
parent
5f2b5fe7be
commit
6c38cdcadb
4 changed files with 58 additions and 1 deletions
|
@ -6920,6 +6920,12 @@ pub enum GrantObjects {
|
||||||
AllSequencesInSchema { schemas: Vec<ObjectName> },
|
AllSequencesInSchema { schemas: Vec<ObjectName> },
|
||||||
/// Grant privileges on `ALL TABLES IN SCHEMA <schema_name> [, ...]`
|
/// Grant privileges on `ALL TABLES IN SCHEMA <schema_name> [, ...]`
|
||||||
AllTablesInSchema { schemas: Vec<ObjectName> },
|
AllTablesInSchema { schemas: Vec<ObjectName> },
|
||||||
|
/// Grant privileges on `FUTURE SCHEMAS IN DATABASE <database_name> [, ...]`
|
||||||
|
FutureSchemasInDatabase { databases: Vec<ObjectName> },
|
||||||
|
/// Grant privileges on `FUTURE TABLES IN SCHEMA <schema_name> [, ...]`
|
||||||
|
FutureTablesInSchema { schemas: Vec<ObjectName> },
|
||||||
|
/// Grant privileges on `FUTURE VIEWS IN SCHEMA <schema_name> [, ...]`
|
||||||
|
FutureViewsInSchema { schemas: Vec<ObjectName> },
|
||||||
/// Grant privileges on specific databases
|
/// Grant privileges on specific databases
|
||||||
Databases(Vec<ObjectName>),
|
Databases(Vec<ObjectName>),
|
||||||
/// Grant privileges on specific schemas
|
/// Grant privileges on specific schemas
|
||||||
|
@ -6988,6 +6994,27 @@ impl fmt::Display for GrantObjects {
|
||||||
display_comma_separated(schemas)
|
display_comma_separated(schemas)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
GrantObjects::FutureSchemasInDatabase { databases } => {
|
||||||
|
write!(
|
||||||
|
f,
|
||||||
|
"FUTURE SCHEMAS IN DATABASE {}",
|
||||||
|
display_comma_separated(databases)
|
||||||
|
)
|
||||||
|
}
|
||||||
|
GrantObjects::FutureTablesInSchema { schemas } => {
|
||||||
|
write!(
|
||||||
|
f,
|
||||||
|
"FUTURE TABLES IN SCHEMA {}",
|
||||||
|
display_comma_separated(schemas)
|
||||||
|
)
|
||||||
|
}
|
||||||
|
GrantObjects::FutureViewsInSchema { schemas } => {
|
||||||
|
write!(
|
||||||
|
f,
|
||||||
|
"FUTURE VIEWS IN SCHEMA {}",
|
||||||
|
display_comma_separated(schemas)
|
||||||
|
)
|
||||||
|
}
|
||||||
GrantObjects::ResourceMonitors(objects) => {
|
GrantObjects::ResourceMonitors(objects) => {
|
||||||
write!(f, "RESOURCE MONITOR {}", display_comma_separated(objects))
|
write!(f, "RESOURCE MONITOR {}", display_comma_separated(objects))
|
||||||
}
|
}
|
||||||
|
|
|
@ -395,6 +395,7 @@ define_keywords!(
|
||||||
FUNCTION,
|
FUNCTION,
|
||||||
FUNCTIONS,
|
FUNCTIONS,
|
||||||
FUSION,
|
FUSION,
|
||||||
|
FUTURE,
|
||||||
GENERAL,
|
GENERAL,
|
||||||
GENERATE,
|
GENERATE,
|
||||||
GENERATED,
|
GENERATED,
|
||||||
|
|
|
@ -13691,6 +13691,33 @@ impl<'a> Parser<'a> {
|
||||||
Some(GrantObjects::AllTablesInSchema {
|
Some(GrantObjects::AllTablesInSchema {
|
||||||
schemas: self.parse_comma_separated(|p| p.parse_object_name(false))?,
|
schemas: self.parse_comma_separated(|p| p.parse_object_name(false))?,
|
||||||
})
|
})
|
||||||
|
} else if self.parse_keywords(&[
|
||||||
|
Keyword::FUTURE,
|
||||||
|
Keyword::SCHEMAS,
|
||||||
|
Keyword::IN,
|
||||||
|
Keyword::DATABASE,
|
||||||
|
]) {
|
||||||
|
Some(GrantObjects::FutureSchemasInDatabase {
|
||||||
|
databases: self.parse_comma_separated(|p| p.parse_object_name(false))?,
|
||||||
|
})
|
||||||
|
} else if self.parse_keywords(&[
|
||||||
|
Keyword::FUTURE,
|
||||||
|
Keyword::TABLES,
|
||||||
|
Keyword::IN,
|
||||||
|
Keyword::SCHEMA,
|
||||||
|
]) {
|
||||||
|
Some(GrantObjects::FutureTablesInSchema {
|
||||||
|
schemas: self.parse_comma_separated(|p| p.parse_object_name(false))?,
|
||||||
|
})
|
||||||
|
} else if self.parse_keywords(&[
|
||||||
|
Keyword::FUTURE,
|
||||||
|
Keyword::VIEWS,
|
||||||
|
Keyword::IN,
|
||||||
|
Keyword::SCHEMA,
|
||||||
|
]) {
|
||||||
|
Some(GrantObjects::FutureViewsInSchema {
|
||||||
|
schemas: self.parse_comma_separated(|p| p.parse_object_name(false))?,
|
||||||
|
})
|
||||||
} else if self.parse_keywords(&[
|
} else if self.parse_keywords(&[
|
||||||
Keyword::ALL,
|
Keyword::ALL,
|
||||||
Keyword::SEQUENCES,
|
Keyword::SEQUENCES,
|
||||||
|
|
|
@ -9386,9 +9386,11 @@ fn parse_grant() {
|
||||||
verified_stmt("GRANT SELECT ON VIEW view1 TO ROLE role1");
|
verified_stmt("GRANT SELECT ON VIEW view1 TO ROLE role1");
|
||||||
verified_stmt("GRANT EXEC ON my_sp TO runner");
|
verified_stmt("GRANT EXEC ON my_sp TO runner");
|
||||||
verified_stmt("GRANT UPDATE ON my_table TO updater_role AS dbo");
|
verified_stmt("GRANT UPDATE ON my_table TO updater_role AS dbo");
|
||||||
|
|
||||||
all_dialects_where(|d| d.identifier_quote_style("none") == Some('['))
|
all_dialects_where(|d| d.identifier_quote_style("none") == Some('['))
|
||||||
.verified_stmt("GRANT SELECT ON [my_table] TO [public]");
|
.verified_stmt("GRANT SELECT ON [my_table] TO [public]");
|
||||||
|
verified_stmt("GRANT SELECT ON FUTURE SCHEMAS IN DATABASE db1 TO ROLE role1");
|
||||||
|
verified_stmt("GRANT SELECT ON FUTURE TABLES IN SCHEMA db1.sc1 TO ROLE role1");
|
||||||
|
verified_stmt("GRANT SELECT ON FUTURE VIEWS IN SCHEMA db1.sc1 TO ROLE role1");
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue