@@ -31,12 +31,12 @@ use sqlparser_derive::{Visit, VisitMut};
3131use crate :: ast:: value:: escape_single_quote_string;
3232use crate :: ast:: {
3333 display_comma_separated, display_separated, ArgMode , CommentDef , CreateFunctionBody ,
34- CreateFunctionUsing , CreateTableOptions , DataType , Expr , FileFormat , FunctionBehavior ,
35- FunctionCalledOnNull , FunctionDeterminismSpecifier , FunctionParallel , HiveDistributionStyle ,
36- HiveFormat , HiveIOFormat , HiveRowFormat , Ident , MySQLColumnPosition , ObjectName , OnCommit ,
37- OneOrManyWithParens , OperateFunctionArg , OrderByExpr , ProjectionSelect , Query , RowAccessPolicy ,
38- SequenceOptions , Spanned , SqlOption , StorageSerializationPolicy , Tag , Value , ValueWithSpan ,
39- WrappedCollection ,
34+ CreateFunctionUsing , CreateTableLikeKind , CreateTableOptions , DataType , Expr , FileFormat ,
35+ FunctionBehavior , FunctionCalledOnNull , FunctionDeterminismSpecifier , FunctionParallel ,
36+ HiveDistributionStyle , HiveFormat , HiveIOFormat , HiveRowFormat , Ident , MySQLColumnPosition ,
37+ ObjectName , OnCommit , OneOrManyWithParens , OperateFunctionArg , OrderByExpr , ProjectionSelect ,
38+ Query , RowAccessPolicy , SequenceOptions , Spanned , SqlOption , StorageSerializationPolicy , Tag ,
39+ Value , ValueWithSpan , WrappedCollection ,
4040} ;
4141use crate :: display_utils:: { DisplayCommaSeparated , Indent , NewLine , SpaceOrNewline } ;
4242use crate :: keywords:: Keyword ;
@@ -2430,7 +2430,7 @@ pub struct CreateTable {
24302430 pub location : Option < String > ,
24312431 pub query : Option < Box < Query > > ,
24322432 pub without_rowid : bool ,
2433- pub like : Option < ObjectName > ,
2433+ pub like : Option < CreateTableLikeKind > ,
24342434 pub clone : Option < ObjectName > ,
24352435 // For Hive dialect, the table comment is after the column definitions without `=`,
24362436 // so the `comment` field is optional and different than the comment field in the general options list.
@@ -2559,6 +2559,8 @@ impl fmt::Display for CreateTable {
25592559 } else if self . query . is_none ( ) && self . like . is_none ( ) && self . clone . is_none ( ) {
25602560 // PostgreSQL allows `CREATE TABLE t ();`, but requires empty parens
25612561 f. write_str ( " ()" ) ?;
2562+ } else if let Some ( CreateTableLikeKind :: Parenthesized ( like_in_columns_list) ) = & self . like {
2563+ write ! ( f, " ({like_in_columns_list})" ) ?;
25622564 }
25632565
25642566 // Hive table comment should be after column definitions, please refer to:
@@ -2572,9 +2574,8 @@ impl fmt::Display for CreateTable {
25722574 write ! ( f, " WITHOUT ROWID" ) ?;
25732575 }
25742576
2575- // Only for Hive
2576- if let Some ( l) = & self . like {
2577- write ! ( f, " LIKE {l}" ) ?;
2577+ if let Some ( CreateTableLikeKind :: Plain ( like) ) = & self . like {
2578+ write ! ( f, " {like}" ) ?;
25782579 }
25792580
25802581 if let Some ( c) = & self . clone {
0 commit comments