@@ -10125,6 +10125,63 @@ impl fmt::Display for MemberOf {
1012510125 }
1012610126}
1012710127
10128+ /// Specifies how to create a new table based on an existing table's schema.
10129+ ///
10130+ /// Not parenthesized:
10131+ /// '''sql
10132+ /// CREATE TABLE new LIKE old ...
10133+ /// '''
10134+ /// [Snowflake](https://docs.snowflake.com/en/sql-reference/sql/create-table#label-create-table-like)
10135+ /// [BigQuery](https://cloud.google.com/bigquery/docs/reference/standard-sql/data-definition-language#create_table_like)
10136+ ///
10137+ /// Parenthesized:
10138+ /// '''sql
10139+ /// CREATE TABLE new (LIKE old ...)
10140+ /// '''
10141+ /// [Redshift](https://docs.aws.amazon.com/redshift/latest/dg/r_CREATE_TABLE_NEW.html)
10142+ #[ derive( Debug , Clone , PartialEq , PartialOrd , Eq , Ord , Hash ) ]
10143+ #[ cfg_attr( feature = "serde" , derive( Serialize , Deserialize ) ) ]
10144+ #[ cfg_attr( feature = "visitor" , derive( Visit , VisitMut ) ) ]
10145+ pub enum CreateTableLikeKind {
10146+ Parenthesized ( CreateTableLike ) ,
10147+ NotParenthesized ( CreateTableLike ) ,
10148+ }
10149+
10150+ #[ derive( Debug , Copy , Clone , PartialEq , PartialOrd , Eq , Ord , Hash ) ]
10151+ #[ cfg_attr( feature = "serde" , derive( Serialize , Deserialize ) ) ]
10152+ #[ cfg_attr( feature = "visitor" , derive( Visit , VisitMut ) ) ]
10153+ pub enum CreateTableLikeDefaults {
10154+ Including ,
10155+ Excluding ,
10156+ }
10157+
10158+ impl fmt:: Display for CreateTableLikeDefaults {
10159+ fn fmt ( & self , f : & mut fmt:: Formatter ) -> fmt:: Result {
10160+ match self {
10161+ CreateTableLikeDefaults :: Including => write ! ( f, "INCLUDING DEFAULTS" ) ,
10162+ CreateTableLikeDefaults :: Excluding => write ! ( f, "EXCLUDING DEFAULTS" ) ,
10163+ }
10164+ }
10165+ }
10166+
10167+ #[ derive( Debug , Clone , PartialEq , PartialOrd , Eq , Ord , Hash ) ]
10168+ #[ cfg_attr( feature = "serde" , derive( Serialize , Deserialize ) ) ]
10169+ #[ cfg_attr( feature = "visitor" , derive( Visit , VisitMut ) ) ]
10170+ pub struct CreateTableLike {
10171+ pub name : ObjectName ,
10172+ pub defaults : Option < CreateTableLikeDefaults > ,
10173+ }
10174+
10175+ impl fmt:: Display for CreateTableLike {
10176+ fn fmt ( & self , f : & mut fmt:: Formatter ) -> fmt:: Result {
10177+ write ! ( f, "LIKE {}" , self . name) ?;
10178+ if let Some ( defaults) = & self . defaults {
10179+ write ! ( f, " {defaults}" ) ?;
10180+ }
10181+ Ok ( ( ) )
10182+ }
10183+ }
10184+
1012810185#[ cfg( test) ]
1012910186mod tests {
1013010187 use crate :: tokenizer:: Location ;
0 commit comments