@@ -2001,6 +2001,7 @@ pub enum Statement {
20012001 if_exists : bool ,
20022002 only : bool ,
20032003 operations : Vec < AlterTableOperation > ,
2004+ location : Option < HiveSetLocation > ,
20042005 } ,
20052006 /// ```sql
20062007 /// ALTER INDEX
@@ -3249,12 +3250,10 @@ impl fmt::Display for Statement {
32493250 }
32503251 }
32513252 if * external {
3252- write ! (
3253- f,
3254- " STORED AS {} LOCATION '{}'" ,
3255- file_format. as_ref( ) . unwrap( ) ,
3256- location. as_ref( ) . unwrap( )
3257- ) ?;
3253+ if let Some ( file_format) = & file_format {
3254+ write ! ( f, " STORED AS {file_format}" ) ?;
3255+ }
3256+ write ! ( f, " LOCATION '{}'" , location. as_ref( ) . unwrap( ) ) ?;
32583257 }
32593258 if !table_properties. is_empty ( ) {
32603259 write ! (
@@ -3504,6 +3503,7 @@ impl fmt::Display for Statement {
35043503 if_exists,
35053504 only,
35063505 operations,
3506+ location,
35073507 } => {
35083508 write ! ( f, "ALTER TABLE " ) ?;
35093509 if * if_exists {
@@ -3516,7 +3516,11 @@ impl fmt::Display for Statement {
35163516 f,
35173517 "{name} {operations}" ,
35183518 operations = display_comma_separated( operations)
3519- )
3519+ ) ?;
3520+ if let Some ( loc) = location {
3521+ write ! ( f, " {loc}" ) ?
3522+ }
3523+ Ok ( ( ) )
35203524 }
35213525 Statement :: AlterIndex { name, operation } => {
35223526 write ! ( f, "ALTER INDEX {name} {operation}" )
@@ -5840,6 +5844,23 @@ impl fmt::Display for LockTableType {
58405844 }
58415845}
58425846
5847+ #[ derive( Debug , Clone , PartialEq , PartialOrd , Eq , Ord , Hash ) ]
5848+ #[ cfg_attr( feature = "serde" , derive( Serialize , Deserialize ) ) ]
5849+ #[ cfg_attr( feature = "visitor" , derive( Visit , VisitMut ) ) ]
5850+ pub struct HiveSetLocation {
5851+ pub has_set : bool ,
5852+ pub location : Ident ,
5853+ }
5854+
5855+ impl fmt:: Display for HiveSetLocation {
5856+ fn fmt ( & self , f : & mut fmt:: Formatter < ' _ > ) -> fmt:: Result {
5857+ if self . has_set {
5858+ write ! ( f, "SET " ) ?;
5859+ }
5860+ write ! ( f, "LOCATION {}" , self . location)
5861+ }
5862+ }
5863+
58435864#[ cfg( test) ]
58445865mod tests {
58455866 use super :: * ;
0 commit comments