diff --git a/src/ast/mod.rs b/src/ast/mod.rs index 6a25d2aba..ebb2dcd0a 100644 --- a/src/ast/mod.rs +++ b/src/ast/mod.rs @@ -8376,6 +8376,8 @@ pub enum Action { /// Read access. Read, + /// Write access. + Write, /// Read session-level access. ReadSession, /// References with optional column list. @@ -8469,6 +8471,7 @@ impl fmt::Display for Action { Action::Ownership => f.write_str("OWNERSHIP")?, Action::PurchaseDataExchangeListing => f.write_str("PURCHASE DATA EXCHANGE LISTING")?, Action::Read => f.write_str("READ")?, + Action::Write => f.write_str("WRITE")?, Action::ReadSession => f.write_str("READ SESSION")?, Action::References { .. } => f.write_str("REFERENCES")?, Action::Replicate => f.write_str("REPLICATE")?, @@ -8537,6 +8540,8 @@ pub enum ActionCreateObjectType { Schema, /// A share object. Share, + /// A table object. + Table, /// A user object. User, /// A warehouse object. @@ -8563,6 +8568,7 @@ impl fmt::Display for ActionCreateObjectType { ActionCreateObjectType::Role => write!(f, "ROLE"), ActionCreateObjectType::Schema => write!(f, "SCHEMA"), ActionCreateObjectType::Share => write!(f, "SHARE"), + ActionCreateObjectType::Table => write!(f, "TABLE"), ActionCreateObjectType::User => write!(f, "USER"), ActionCreateObjectType::Warehouse => write!(f, "WAREHOUSE"), } @@ -8895,6 +8901,46 @@ pub enum GrantObjects { /// The target schema names. schemas: Vec, }, + /// Grant privileges on `ALL SCHEMAS IN DATABASE [, ...]` + AllSchemasInDatabase { + /// The target database names. + databases: Vec, + }, + /// Grant privileges on `ALL TABLES IN DATABASE [, ...]` + AllTablesInDatabase { + /// The target database names. + databases: Vec, + }, + /// Grant privileges on `ALL STAGES IN SCHEMA [, ...]` + AllStagesInSchema { + /// The target schema names. + schemas: Vec, + }, + /// Grant privileges on `ALL FILE FORMATS IN SCHEMA [, ...]` + AllFileFormatsInSchema { + /// The target schema names. + schemas: Vec, + }, + /// Grant privileges on `FUTURE TABLES IN DATABASE [, ...]` + FutureTablesInDatabase { + /// The target database names. + databases: Vec, + }, + /// Grant privileges on `FUTURE STAGES IN SCHEMA [, ...]` + FutureStagesInSchema { + /// The target schema names. + schemas: Vec, + }, + /// Grant privileges on `FUTURE FILE FORMATS IN SCHEMA [, ...]` + FutureFileFormatsInSchema { + /// The target schema names. + schemas: Vec, + }, + /// Grant privileges on `FUTURE FUNCTIONS IN SCHEMA [, ...]` + FutureFunctionsInSchema { + /// The target schema names. + schemas: Vec, + }, /// Grant privileges on specific databases Databases(Vec), /// Grant privileges on specific schemas @@ -8913,6 +8959,10 @@ pub enum GrantObjects { ResourceMonitors(Vec), /// Grant privileges on users Users(Vec), + /// Grant privileges on specific stages + Stages(Vec), + /// Grant privileges on specific file formats + FileFormats(Vec), /// Grant privileges on compute pools ComputePools(Vec), /// Grant privileges on connections @@ -9056,12 +9106,74 @@ impl fmt::Display for GrantObjects { display_comma_separated(schemas) ) } + GrantObjects::AllSchemasInDatabase { databases } => { + write!( + f, + "ALL SCHEMAS IN DATABASE {}", + display_comma_separated(databases) + ) + } + GrantObjects::AllTablesInDatabase { databases } => { + write!( + f, + "ALL TABLES IN DATABASE {}", + display_comma_separated(databases) + ) + } + GrantObjects::AllStagesInSchema { schemas } => { + write!( + f, + "ALL STAGES IN SCHEMA {}", + display_comma_separated(schemas) + ) + } + GrantObjects::AllFileFormatsInSchema { schemas } => { + write!( + f, + "ALL FILE FORMATS IN SCHEMA {}", + display_comma_separated(schemas) + ) + } + GrantObjects::FutureTablesInDatabase { databases } => { + write!( + f, + "FUTURE TABLES IN DATABASE {}", + display_comma_separated(databases) + ) + } + GrantObjects::FutureStagesInSchema { schemas } => { + write!( + f, + "FUTURE STAGES IN SCHEMA {}", + display_comma_separated(schemas) + ) + } + GrantObjects::FutureFileFormatsInSchema { schemas } => { + write!( + f, + "FUTURE FILE FORMATS IN SCHEMA {}", + display_comma_separated(schemas) + ) + } + GrantObjects::FutureFunctionsInSchema { schemas } => { + write!( + f, + "FUTURE FUNCTIONS IN SCHEMA {}", + display_comma_separated(schemas) + ) + } GrantObjects::ResourceMonitors(objects) => { write!(f, "RESOURCE MONITOR {}", display_comma_separated(objects)) } GrantObjects::Users(objects) => { write!(f, "USER {}", display_comma_separated(objects)) } + GrantObjects::Stages(objects) => { + write!(f, "STAGE {}", display_comma_separated(objects)) + } + GrantObjects::FileFormats(objects) => { + write!(f, "FILE FORMAT {}", display_comma_separated(objects)) + } GrantObjects::ComputePools(objects) => { write!(f, "COMPUTE POOL {}", display_comma_separated(objects)) } diff --git a/src/parser/mod.rs b/src/parser/mod.rs index f0a160cea..88f1e53e4 100644 --- a/src/parser/mod.rs +++ b/src/parser/mod.rs @@ -18150,6 +18150,80 @@ impl<'a> Parser<'a> { Some(GrantObjects::FutureSequencesInSchema { schemas: self.parse_comma_separated(|p| p.parse_object_name(false))?, }) + } else if self.parse_keywords(&[ + Keyword::ALL, + Keyword::SCHEMAS, + Keyword::IN, + Keyword::DATABASE, + ]) { + Some(GrantObjects::AllSchemasInDatabase { + databases: self.parse_comma_separated(|p| p.parse_object_name(false))?, + }) + } else if self.parse_keywords(&[ + Keyword::ALL, + Keyword::TABLES, + Keyword::IN, + Keyword::DATABASE, + ]) { + Some(GrantObjects::AllTablesInDatabase { + databases: self.parse_comma_separated(|p| p.parse_object_name(false))?, + }) + } else if self.parse_keywords(&[ + Keyword::ALL, + Keyword::STAGES, + Keyword::IN, + Keyword::SCHEMA, + ]) { + Some(GrantObjects::AllStagesInSchema { + schemas: self.parse_comma_separated(|p| p.parse_object_name(false))?, + }) + } else if self.parse_keywords(&[ + Keyword::ALL, + Keyword::FILE, + Keyword::FORMATS, + Keyword::IN, + Keyword::SCHEMA, + ]) { + Some(GrantObjects::AllFileFormatsInSchema { + schemas: self.parse_comma_separated(|p| p.parse_object_name(false))?, + }) + } else if self.parse_keywords(&[ + Keyword::FUTURE, + Keyword::TABLES, + Keyword::IN, + Keyword::DATABASE, + ]) { + Some(GrantObjects::FutureTablesInDatabase { + databases: self.parse_comma_separated(|p| p.parse_object_name(false))?, + }) + } else if self.parse_keywords(&[ + Keyword::FUTURE, + Keyword::STAGES, + Keyword::IN, + Keyword::SCHEMA, + ]) { + Some(GrantObjects::FutureStagesInSchema { + schemas: self.parse_comma_separated(|p| p.parse_object_name(false))?, + }) + } else if self.parse_keywords(&[ + Keyword::FUTURE, + Keyword::FILE, + Keyword::FORMATS, + Keyword::IN, + Keyword::SCHEMA, + ]) { + Some(GrantObjects::FutureFileFormatsInSchema { + schemas: self.parse_comma_separated(|p| p.parse_object_name(false))?, + }) + } else if self.parse_keywords(&[ + Keyword::FUTURE, + Keyword::FUNCTIONS, + Keyword::IN, + Keyword::SCHEMA, + ]) { + Some(GrantObjects::FutureFunctionsInSchema { + schemas: self.parse_comma_separated(|p| p.parse_object_name(false))?, + }) } else if self.parse_keywords(&[Keyword::RESOURCE, Keyword::MONITOR]) { Some(GrantObjects::ResourceMonitors( self.parse_comma_separated(|p| p.parse_object_name(false))?, @@ -18170,6 +18244,14 @@ impl<'a> Parser<'a> { Some(GrantObjects::ExternalVolumes( self.parse_comma_separated(|p| p.parse_object_name(false))?, )) + } else if self.parse_keywords(&[Keyword::FILE, Keyword::FORMAT]) { + Some(GrantObjects::FileFormats( + self.parse_comma_separated(|p| p.parse_object_name(false))?, + )) + } else if self.parse_keyword(Keyword::STAGE) { + Some(GrantObjects::Stages( + self.parse_comma_separated(|p| p.parse_object_name(false))?, + )) } else { let object_type = self.parse_one_of_keywords(&[ Keyword::SEQUENCE, @@ -18334,6 +18416,8 @@ impl<'a> Parser<'a> { }) } else if self.parse_keyword(Keyword::READ) { Ok(Action::Read) + } else if self.parse_keyword(Keyword::WRITE) { + Ok(Action::Write) } else if self.parse_keyword(Keyword::REPLICATE) { Ok(Action::Replicate) } else if self.parse_keyword(Keyword::ROLE) { @@ -18400,6 +18484,8 @@ impl<'a> Parser<'a> { Some(ActionCreateObjectType::Schema) } else if self.parse_keyword(Keyword::SHARE) { Some(ActionCreateObjectType::Share) + } else if self.parse_keyword(Keyword::TABLE) { + Some(ActionCreateObjectType::Table) } else if self.parse_keyword(Keyword::USER) { Some(ActionCreateObjectType::User) } else if self.parse_keyword(Keyword::WAREHOUSE) {