mirror of
https://github.com/apache/datafusion-sqlparser-rs.git
synced 2025-08-22 15:04:04 +00:00
Add Snowflake COPY/REVOKE CURRENT GRANTS
option (#1926)
Some checks failed
license / Release Audit Tool (RAT) (push) Has been cancelled
Rust / codestyle (push) Has been cancelled
Rust / lint (push) Has been cancelled
Rust / benchmark-lint (push) Has been cancelled
Rust / compile (push) Has been cancelled
Rust / docs (push) Has been cancelled
Rust / compile-no-std (push) Has been cancelled
Rust / test (beta) (push) Has been cancelled
Rust / test (nightly) (push) Has been cancelled
Rust / test (stable) (push) Has been cancelled
Some checks failed
license / Release Audit Tool (RAT) (push) Has been cancelled
Rust / codestyle (push) Has been cancelled
Rust / lint (push) Has been cancelled
Rust / benchmark-lint (push) Has been cancelled
Rust / compile (push) Has been cancelled
Rust / docs (push) Has been cancelled
Rust / compile-no-std (push) Has been cancelled
Rust / test (beta) (push) Has been cancelled
Rust / test (nightly) (push) Has been cancelled
Rust / test (stable) (push) Has been cancelled
This commit is contained in:
parent
1a33abda63
commit
93450cc250
4 changed files with 40 additions and 0 deletions
|
@ -3996,6 +3996,7 @@ pub enum Statement {
|
||||||
with_grant_option: bool,
|
with_grant_option: bool,
|
||||||
as_grantor: Option<Ident>,
|
as_grantor: Option<Ident>,
|
||||||
granted_by: Option<Ident>,
|
granted_by: Option<Ident>,
|
||||||
|
current_grants: Option<CurrentGrantsKind>,
|
||||||
},
|
},
|
||||||
/// ```sql
|
/// ```sql
|
||||||
/// DENY privileges ON object TO grantees
|
/// DENY privileges ON object TO grantees
|
||||||
|
@ -4312,6 +4313,28 @@ pub enum Statement {
|
||||||
Return(ReturnStatement),
|
Return(ReturnStatement),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// ```sql
|
||||||
|
/// {COPY | REVOKE} CURRENT GRANTS
|
||||||
|
/// ```
|
||||||
|
///
|
||||||
|
/// - [Snowflake](https://docs.snowflake.com/en/sql-reference/sql/grant-ownership#optional-parameters)
|
||||||
|
#[derive(Debug, Clone, PartialEq, PartialOrd, Eq, Ord, Hash)]
|
||||||
|
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
|
||||||
|
#[cfg_attr(feature = "visitor", derive(Visit, VisitMut))]
|
||||||
|
pub enum CurrentGrantsKind {
|
||||||
|
CopyCurrentGrants,
|
||||||
|
RevokeCurrentGrants,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl fmt::Display for CurrentGrantsKind {
|
||||||
|
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||||
|
match self {
|
||||||
|
CurrentGrantsKind::CopyCurrentGrants => write!(f, "COPY CURRENT GRANTS"),
|
||||||
|
CurrentGrantsKind::RevokeCurrentGrants => write!(f, "REVOKE CURRENT GRANTS"),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone, PartialEq, PartialOrd, Eq, Ord, Hash)]
|
#[derive(Debug, Clone, PartialEq, PartialOrd, Eq, Ord, Hash)]
|
||||||
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
|
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
|
||||||
#[cfg_attr(feature = "visitor", derive(Visit, VisitMut))]
|
#[cfg_attr(feature = "visitor", derive(Visit, VisitMut))]
|
||||||
|
@ -5715,6 +5738,7 @@ impl fmt::Display for Statement {
|
||||||
with_grant_option,
|
with_grant_option,
|
||||||
as_grantor,
|
as_grantor,
|
||||||
granted_by,
|
granted_by,
|
||||||
|
current_grants,
|
||||||
} => {
|
} => {
|
||||||
write!(f, "GRANT {privileges} ")?;
|
write!(f, "GRANT {privileges} ")?;
|
||||||
if let Some(objects) = objects {
|
if let Some(objects) = objects {
|
||||||
|
@ -5724,6 +5748,9 @@ impl fmt::Display for Statement {
|
||||||
if *with_grant_option {
|
if *with_grant_option {
|
||||||
write!(f, " WITH GRANT OPTION")?;
|
write!(f, " WITH GRANT OPTION")?;
|
||||||
}
|
}
|
||||||
|
if let Some(current_grants) = current_grants {
|
||||||
|
write!(f, " {current_grants}")?;
|
||||||
|
}
|
||||||
if let Some(grantor) = as_grantor {
|
if let Some(grantor) = as_grantor {
|
||||||
write!(f, " AS {grantor}")?;
|
write!(f, " AS {grantor}")?;
|
||||||
}
|
}
|
||||||
|
|
|
@ -13794,6 +13794,15 @@ impl<'a> Parser<'a> {
|
||||||
let with_grant_option =
|
let with_grant_option =
|
||||||
self.parse_keywords(&[Keyword::WITH, Keyword::GRANT, Keyword::OPTION]);
|
self.parse_keywords(&[Keyword::WITH, Keyword::GRANT, Keyword::OPTION]);
|
||||||
|
|
||||||
|
let current_grants =
|
||||||
|
if self.parse_keywords(&[Keyword::COPY, Keyword::CURRENT, Keyword::GRANTS]) {
|
||||||
|
Some(CurrentGrantsKind::CopyCurrentGrants)
|
||||||
|
} else if self.parse_keywords(&[Keyword::REVOKE, Keyword::CURRENT, Keyword::GRANTS]) {
|
||||||
|
Some(CurrentGrantsKind::RevokeCurrentGrants)
|
||||||
|
} else {
|
||||||
|
None
|
||||||
|
};
|
||||||
|
|
||||||
let as_grantor = if self.parse_keywords(&[Keyword::AS]) {
|
let as_grantor = if self.parse_keywords(&[Keyword::AS]) {
|
||||||
Some(self.parse_identifier()?)
|
Some(self.parse_identifier()?)
|
||||||
} else {
|
} else {
|
||||||
|
@ -13813,6 +13822,7 @@ impl<'a> Parser<'a> {
|
||||||
with_grant_option,
|
with_grant_option,
|
||||||
as_grantor,
|
as_grantor,
|
||||||
granted_by,
|
granted_by,
|
||||||
|
current_grants,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -9440,6 +9440,8 @@ fn parse_grant() {
|
||||||
verified_stmt("GRANT USAGE ON SCHEMA sc1 TO a:b");
|
verified_stmt("GRANT USAGE ON SCHEMA sc1 TO a:b");
|
||||||
verified_stmt("GRANT USAGE ON SCHEMA sc1 TO GROUP group1");
|
verified_stmt("GRANT USAGE ON SCHEMA sc1 TO GROUP group1");
|
||||||
verified_stmt("GRANT OWNERSHIP ON ALL TABLES IN SCHEMA DEV_STAS_ROGOZHIN TO ROLE ANALYST");
|
verified_stmt("GRANT OWNERSHIP ON ALL TABLES IN SCHEMA DEV_STAS_ROGOZHIN TO ROLE ANALYST");
|
||||||
|
verified_stmt("GRANT OWNERSHIP ON ALL TABLES IN SCHEMA DEV_STAS_ROGOZHIN TO ROLE ANALYST COPY CURRENT GRANTS");
|
||||||
|
verified_stmt("GRANT OWNERSHIP ON ALL TABLES IN SCHEMA DEV_STAS_ROGOZHIN TO ROLE ANALYST REVOKE CURRENT GRANTS");
|
||||||
verified_stmt("GRANT USAGE ON DATABASE db1 TO ROLE role1");
|
verified_stmt("GRANT USAGE ON DATABASE db1 TO ROLE role1");
|
||||||
verified_stmt("GRANT USAGE ON WAREHOUSE wh1 TO ROLE role1");
|
verified_stmt("GRANT USAGE ON WAREHOUSE wh1 TO ROLE role1");
|
||||||
verified_stmt("GRANT OWNERSHIP ON INTEGRATION int1 TO ROLE role1");
|
verified_stmt("GRANT OWNERSHIP ON INTEGRATION int1 TO ROLE role1");
|
||||||
|
|
|
@ -3616,6 +3616,7 @@ fn parse_grant() {
|
||||||
with_grant_option,
|
with_grant_option,
|
||||||
as_grantor: _,
|
as_grantor: _,
|
||||||
granted_by,
|
granted_by,
|
||||||
|
current_grants: _,
|
||||||
} = stmt
|
} = stmt
|
||||||
{
|
{
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue