@@ -31,12 +31,12 @@ use sqlparser_derive::{Visit, VisitMut};
31
31
use crate :: ast:: value:: escape_single_quote_string;
32
32
use crate :: ast:: {
33
33
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 ,
40
40
} ;
41
41
use crate :: display_utils:: { DisplayCommaSeparated , Indent , NewLine , SpaceOrNewline } ;
42
42
use crate :: keywords:: Keyword ;
@@ -2430,7 +2430,7 @@ pub struct CreateTable {
2430
2430
pub location : Option < String > ,
2431
2431
pub query : Option < Box < Query > > ,
2432
2432
pub without_rowid : bool ,
2433
- pub like : Option < ObjectName > ,
2433
+ pub like : Option < CreateTableLikeKind > ,
2434
2434
pub clone : Option < ObjectName > ,
2435
2435
// For Hive dialect, the table comment is after the column definitions without `=`,
2436
2436
// 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 {
2559
2559
} else if self . query . is_none ( ) && self . like . is_none ( ) && self . clone . is_none ( ) {
2560
2560
// PostgreSQL allows `CREATE TABLE t ();`, but requires empty parens
2561
2561
f. write_str ( " ()" ) ?;
2562
+ } else if let Some ( CreateTableLikeKind :: Parenthesized ( like_in_columns_list) ) = & self . like {
2563
+ write ! ( f, " ({like_in_columns_list})" ) ?;
2562
2564
}
2563
2565
2564
2566
// Hive table comment should be after column definitions, please refer to:
@@ -2572,9 +2574,8 @@ impl fmt::Display for CreateTable {
2572
2574
write ! ( f, " WITHOUT ROWID" ) ?;
2573
2575
}
2574
2576
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}" ) ?;
2578
2579
}
2579
2580
2580
2581
if let Some ( c) = & self . clone {
0 commit comments