@@ -4355,7 +4355,6 @@ pub enum Statement {
43554355 ///
43564356 /// See [ReturnStatement]
43574357 Return ( ReturnStatement ) ,
4358-
43594358 /// Export data statement
43604359 ///
43614360 /// Example:
@@ -4364,6 +4363,11 @@ pub enum Statement {
43644363 /// SELECT field1, field2 FROM mydataset.table1 ORDER BY field1 LIMIT 10
43654364 /// ```
43664365 ExportData ( ExportData ) ,
4366+ /// ```sql
4367+ /// CREATE [OR REPLACE] USER <user> [IF NOT EXISTS]
4368+ /// ```
4369+ /// [Snowflake](https://docs.snowflake.com/en/sql-reference/sql/create-user)
4370+ CreateUser ( CreateUser ) ,
43674371}
43684372
43694373/// ```sql
@@ -6203,6 +6207,7 @@ impl fmt::Display for Statement {
62036207 Statement :: List ( command) => write ! ( f, "LIST {command}" ) ,
62046208 Statement :: Remove ( command) => write ! ( f, "REMOVE {command}" ) ,
62056209 Statement :: ExportData ( e) => write ! ( f, "{e}" ) ,
6210+ Statement :: CreateUser ( s) => write ! ( f, "{s}" ) ,
62066211 }
62076212 }
62086213}
@@ -6658,7 +6663,7 @@ pub enum Action {
66586663 Replicate ,
66596664 ResolveAll ,
66606665 Role {
6661- role : Ident ,
6666+ role : ObjectName ,
66626667 } ,
66636668 Select {
66646669 columns : Option < Vec < Ident > > ,
@@ -10148,6 +10153,49 @@ impl fmt::Display for ExportData {
1014810153 write ! ( f, "EXPORT DATA OPTIONS({}) AS {}" , display_comma_separated( & self . options) , self . query)
1014910154 }
1015010155}
10156+ /// Creates a user
10157+ ///
10158+ /// Syntax:
10159+ /// ```sql
10160+ /// CREATE [OR REPLACE] USER [IF NOT EXISTS] <name> [OPTIONS]
10161+ /// ```
10162+ ///
10163+ /// [Snowflake](https://docs.snowflake.com/en/sql-reference/sql/create-user)
10164+ #[ derive( Debug , Clone , PartialEq , PartialOrd , Eq , Ord , Hash ) ]
10165+ #[ cfg_attr( feature = "serde" , derive( Serialize , Deserialize ) ) ]
10166+ #[ cfg_attr( feature = "visitor" , derive( Visit , VisitMut ) ) ]
10167+ pub struct CreateUser {
10168+ pub or_replace : bool ,
10169+ pub if_not_exists : bool ,
10170+ pub name : Ident ,
10171+ pub options : KeyValueOptions ,
10172+ pub with_tags : bool ,
10173+ pub tags : KeyValueOptions ,
10174+ }
10175+
10176+ impl fmt:: Display for CreateUser {
10177+ fn fmt ( & self , f : & mut fmt:: Formatter ) -> fmt:: Result {
10178+ write ! ( f, "CREATE" ) ?;
10179+ if self . or_replace {
10180+ write ! ( f, " OR REPLACE" ) ?;
10181+ }
10182+ write ! ( f, " USER" ) ?;
10183+ if self . if_not_exists {
10184+ write ! ( f, " IF NOT EXISTS" ) ?;
10185+ }
10186+ write ! ( f, " {}" , self . name) ?;
10187+ if !self . options . options . is_empty ( ) {
10188+ write ! ( f, " {}" , self . options) ?;
10189+ }
10190+ if !self . tags . options . is_empty ( ) {
10191+ if self . with_tags {
10192+ write ! ( f, " WITH" ) ?;
10193+ }
10194+ write ! ( f, " TAG ({})" , self . tags) ?;
10195+ }
10196+ Ok ( ( ) )
10197+ }
10198+ }
1015110199
1015210200#[ cfg( test) ]
1015310201mod tests {
0 commit comments