mirror of
https://github.com/apache/datafusion-sqlparser-rs.git
synced 2025-10-09 21:42:05 +00:00
Snowflake: Add support for CREATE USER
(#1950)
This commit is contained in:
parent
492184643a
commit
2ed2cbe291
6 changed files with 281 additions and 85 deletions
|
@ -4355,6 +4355,11 @@ pub enum Statement {
|
|||
///
|
||||
/// See [ReturnStatement]
|
||||
Return(ReturnStatement),
|
||||
/// ```sql
|
||||
/// CREATE [OR REPLACE] USER <user> [IF NOT EXISTS]
|
||||
/// ```
|
||||
/// [Snowflake](https://docs.snowflake.com/en/sql-reference/sql/create-user)
|
||||
CreateUser(CreateUser),
|
||||
}
|
||||
|
||||
/// ```sql
|
||||
|
@ -6193,6 +6198,7 @@ impl fmt::Display for Statement {
|
|||
Statement::Return(r) => write!(f, "{r}"),
|
||||
Statement::List(command) => write!(f, "LIST {command}"),
|
||||
Statement::Remove(command) => write!(f, "REMOVE {command}"),
|
||||
Statement::CreateUser(s) => write!(f, "{s}"),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -10125,6 +10131,50 @@ impl fmt::Display for MemberOf {
|
|||
}
|
||||
}
|
||||
|
||||
/// Creates a user
|
||||
///
|
||||
/// Syntax:
|
||||
/// ```sql
|
||||
/// CREATE [OR REPLACE] USER [IF NOT EXISTS] <name> [OPTIONS]
|
||||
/// ```
|
||||
///
|
||||
/// [Snowflake](https://docs.snowflake.com/en/sql-reference/sql/create-user)
|
||||
#[derive(Debug, Clone, PartialEq, PartialOrd, Eq, Ord, Hash)]
|
||||
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
|
||||
#[cfg_attr(feature = "visitor", derive(Visit, VisitMut))]
|
||||
pub struct CreateUser {
|
||||
pub or_replace: bool,
|
||||
pub if_not_exists: bool,
|
||||
pub name: Ident,
|
||||
pub options: KeyValueOptions,
|
||||
pub with_tags: bool,
|
||||
pub tags: KeyValueOptions,
|
||||
}
|
||||
|
||||
impl fmt::Display for CreateUser {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
write!(f, "CREATE")?;
|
||||
if self.or_replace {
|
||||
write!(f, " OR REPLACE")?;
|
||||
}
|
||||
write!(f, " USER")?;
|
||||
if self.if_not_exists {
|
||||
write!(f, " IF NOT EXISTS")?;
|
||||
}
|
||||
write!(f, " {}", self.name)?;
|
||||
if !self.options.options.is_empty() {
|
||||
write!(f, " {}", self.options)?;
|
||||
}
|
||||
if !self.tags.options.is_empty() {
|
||||
if self.with_tags {
|
||||
write!(f, " WITH")?;
|
||||
}
|
||||
write!(f, " TAG ({})", self.tags)?;
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use crate::tokenizer::Location;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue