@@ -1098,6 +1098,13 @@ impl fmt::Display for ColumnOptionDef {
1098
1098
}
1099
1099
}
1100
1100
1101
+ /// Identity is a column option for defining an identity or autoincrement column in a creating table statement.
1102
+ /// Syntax
1103
+ /// ```sql
1104
+ /// { IDENTITY | AUTOINCREMENT } [ (seed , increment) | START num INCREMENT num ] [ ORDER | NOORDER ]
1105
+ /// ```
1106
+ /// [MS SQL Server]: https://learn.microsoft.com/en-us/sql/t-sql/statements/create-table-transact-sql-identity-property
1107
+ /// [Snowflake]: https://docs.snowflake.com/en/sql-reference/sql/create-table
1101
1108
#[ derive( Debug , Clone , PartialEq , PartialOrd , Eq , Ord , Hash ) ]
1102
1109
#[ cfg_attr( feature = "serde" , derive( Serialize , Deserialize ) ) ]
1103
1110
#[ cfg_attr( feature = "visitor" , derive( Visit , VisitMut ) ) ]
@@ -1114,6 +1121,20 @@ pub struct IdentityProperty {
1114
1121
pub order : Option < IdentityOrder > ,
1115
1122
}
1116
1123
1124
+ /// A format of parameters of identity column.
1125
+ ///
1126
+ /// It is [Snowflake] specific.
1127
+ /// Syntax
1128
+ /// ```sql
1129
+ /// (seed , increment) | START num INCREMENT num
1130
+ /// ```
1131
+ /// [MS SQL Server] uses one way of representing these parameters.
1132
+ /// Syntax
1133
+ /// ```sql
1134
+ /// (seed , increment)
1135
+ /// ```
1136
+ /// [MS SQL Server]: https://learn.microsoft.com/en-us/sql/t-sql/statements/create-table-transact-sql-identity-property
1137
+ /// [Snowflake]: https://docs.snowflake.com/en/sql-reference/sql/create-table
1117
1138
#[ derive( Debug , Clone , PartialEq , PartialOrd , Eq , Ord , Hash ) ]
1118
1139
#[ cfg_attr( feature = "serde" , derive( Serialize , Deserialize ) ) ]
1119
1140
#[ cfg_attr( feature = "visitor" , derive( Visit , VisitMut ) ) ]
@@ -1135,7 +1156,7 @@ pub struct IdentityParameters {
1135
1156
#[ cfg_attr( feature = "visitor" , derive( Visit , VisitMut ) ) ]
1136
1157
pub enum IdentityOrder {
1137
1158
Order ,
1138
- Noorder ,
1159
+ NoOrder ,
1139
1160
}
1140
1161
1141
1162
impl fmt:: Display for Identity {
@@ -1176,11 +1197,18 @@ impl fmt::Display for IdentityOrder {
1176
1197
fn fmt ( & self , f : & mut fmt:: Formatter ) -> fmt:: Result {
1177
1198
match self {
1178
1199
IdentityOrder :: Order => write ! ( f, " ORDER" ) ,
1179
- IdentityOrder :: Noorder => write ! ( f, " NOORDER" ) ,
1200
+ IdentityOrder :: NoOrder => write ! ( f, " NOORDER" ) ,
1180
1201
}
1181
1202
}
1182
1203
}
1183
1204
1205
+ /// Column policy that identify a security policy of access to a column.
1206
+ /// Syntax
1207
+ /// ```sql
1208
+ /// [ WITH ] MASKING POLICY <policy_name> [ USING ( <col_name> , <cond_col1> , ... ) ]
1209
+ /// [ WITH ] PROJECTION POLICY <policy_name>
1210
+ /// ```
1211
+ /// [Snowflake]: https://docs.snowflake.com/en/sql-reference/sql/create-table
1184
1212
#[ derive( Debug , Clone , PartialEq , PartialOrd , Eq , Ord , Hash ) ]
1185
1213
#[ cfg_attr( feature = "serde" , derive( Serialize , Deserialize ) ) ]
1186
1214
#[ cfg_attr( feature = "visitor" , derive( Visit , VisitMut ) ) ]
@@ -1193,6 +1221,7 @@ pub enum ColumnPolicy {
1193
1221
#[ cfg_attr( feature = "serde" , derive( Serialize , Deserialize ) ) ]
1194
1222
#[ cfg_attr( feature = "visitor" , derive( Visit , VisitMut ) ) ]
1195
1223
pub struct ColumnPolicyProperty {
1224
+ pub with : bool ,
1196
1225
pub policy_name : Ident ,
1197
1226
pub using_columns : Option < Vec < Ident > > ,
1198
1227
}
@@ -1203,10 +1232,37 @@ impl fmt::Display for ColumnPolicy {
1203
1232
ColumnPolicy :: MaskingPolicy ( property) => ( "MASKING POLICY" , property) ,
1204
1233
ColumnPolicy :: ProjectionPolicy ( property) => ( "PROJECTION POLICY" , property) ,
1205
1234
} ;
1206
- write ! ( f, "WITH {command} {}" , property. policy_name) ?;
1235
+ if property. with {
1236
+ write ! ( f, "WITH " ) ?;
1237
+ }
1238
+ write ! ( f, "{command} {}" , property. policy_name) ?;
1207
1239
if let Some ( using_columns) = & property. using_columns {
1208
- write ! ( f, "USING ({})" , display_comma_separated( using_columns) ) ?;
1240
+ write ! ( f, " USING ({})" , display_comma_separated( using_columns) ) ?;
1241
+ }
1242
+ Ok ( ( ) )
1243
+ }
1244
+ }
1245
+
1246
+ /// Tags option of column
1247
+ /// Syntax
1248
+ /// ```sql
1249
+ /// [ WITH ] TAG ( <tag_name> = '<tag_value>' [ , <tag_name> = '<tag_value>' , ... ] )
1250
+ /// ```
1251
+ /// [Snowflake]: https://docs.snowflake.com/en/sql-reference/sql/create-table
1252
+ #[ derive( Debug , Clone , PartialEq , PartialOrd , Eq , Ord , Hash ) ]
1253
+ #[ cfg_attr( feature = "serde" , derive( Serialize , Deserialize ) ) ]
1254
+ #[ cfg_attr( feature = "visitor" , derive( Visit , VisitMut ) ) ]
1255
+ pub struct TagsColumnOption {
1256
+ pub with : bool ,
1257
+ pub tags : Vec < Tag > ,
1258
+ }
1259
+
1260
+ impl fmt:: Display for TagsColumnOption {
1261
+ fn fmt ( & self , f : & mut fmt:: Formatter ) -> fmt:: Result {
1262
+ if self . with {
1263
+ write ! ( f, "WITH " ) ?;
1209
1264
}
1265
+ write ! ( f, "TAG ({})" , display_comma_separated( & self . tags) ) ?;
1210
1266
Ok ( ( ) )
1211
1267
}
1212
1268
}
@@ -1303,7 +1359,7 @@ pub enum ColumnOption {
1303
1359
/// [ WITH ] TAG ( <tag_name> = '<tag_value>' [ , <tag_name> = '<tag_value>' , ... ] )
1304
1360
/// ```
1305
1361
/// [Snowflake]: https://docs.snowflake.com/en/sql-reference/sql/create-table
1306
- Tags ( Vec < Tag > ) ,
1362
+ Tags ( TagsColumnOption ) ,
1307
1363
}
1308
1364
1309
1365
impl fmt:: Display for ColumnOption {
@@ -1412,7 +1468,7 @@ impl fmt::Display for ColumnOption {
1412
1468
write ! ( f, "{parameters}" )
1413
1469
}
1414
1470
Tags ( tags) => {
1415
- write ! ( f, "WITH TAG ({})" , display_comma_separated ( tags ) )
1471
+ write ! ( f, "{tags}" )
1416
1472
}
1417
1473
}
1418
1474
}
0 commit comments