Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
112 changes: 112 additions & 0 deletions src/ast/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8376,6 +8376,8 @@ pub enum Action {

/// Read access.
Read,
/// Write access.
Write,
/// Read session-level access.
ReadSession,
/// References with optional column list.
Expand Down Expand Up @@ -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")?,
Expand Down Expand Up @@ -8537,6 +8540,8 @@ pub enum ActionCreateObjectType {
Schema,
/// A share object.
Share,
/// A table object.
Table,
/// A user object.
User,
/// A warehouse object.
Expand All @@ -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"),
}
Expand Down Expand Up @@ -8895,6 +8901,46 @@ pub enum GrantObjects {
/// The target schema names.
schemas: Vec<ObjectName>,
},
/// Grant privileges on `ALL SCHEMAS IN DATABASE <database_name> [, ...]`
AllSchemasInDatabase {
/// The target database names.
databases: Vec<ObjectName>,
},
/// Grant privileges on `ALL TABLES IN DATABASE <database_name> [, ...]`
AllTablesInDatabase {
/// The target database names.
databases: Vec<ObjectName>,
},
/// Grant privileges on `ALL STAGES IN SCHEMA <schema_name> [, ...]`
AllStagesInSchema {
/// The target schema names.
schemas: Vec<ObjectName>,
},
/// Grant privileges on `ALL FILE FORMATS IN SCHEMA <schema_name> [, ...]`
AllFileFormatsInSchema {
/// The target schema names.
schemas: Vec<ObjectName>,
},
/// Grant privileges on `FUTURE TABLES IN DATABASE <database_name> [, ...]`
FutureTablesInDatabase {
/// The target database names.
databases: Vec<ObjectName>,
},
/// Grant privileges on `FUTURE STAGES IN SCHEMA <schema_name> [, ...]`
FutureStagesInSchema {
/// The target schema names.
schemas: Vec<ObjectName>,
},
/// Grant privileges on `FUTURE FILE FORMATS IN SCHEMA <schema_name> [, ...]`
FutureFileFormatsInSchema {
/// The target schema names.
schemas: Vec<ObjectName>,
},
/// Grant privileges on `FUTURE FUNCTIONS IN SCHEMA <schema_name> [, ...]`
FutureFunctionsInSchema {
/// The target schema names.
schemas: Vec<ObjectName>,
},
/// Grant privileges on specific databases
Databases(Vec<ObjectName>),
/// Grant privileges on specific schemas
Expand All @@ -8913,6 +8959,10 @@ pub enum GrantObjects {
ResourceMonitors(Vec<ObjectName>),
/// Grant privileges on users
Users(Vec<ObjectName>),
/// Grant privileges on specific stages
Stages(Vec<ObjectName>),
/// Grant privileges on specific file formats
FileFormats(Vec<ObjectName>),
/// Grant privileges on compute pools
ComputePools(Vec<ObjectName>),
/// Grant privileges on connections
Expand Down Expand Up @@ -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))
}
Expand Down
86 changes: 86 additions & 0 deletions src/parser/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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))?,
Expand All @@ -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,
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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) {
Expand Down
Loading