@@ -30,6 +30,20 @@ static const TString defaultStoreSchema = R"(
30
30
}
31
31
)" ;
32
32
33
+ static const TString invalidStoreSchema = R"(
34
+ Name: "OlapStore"
35
+ ColumnShardCount: 1
36
+ SchemaPresets {
37
+ Name: "default"
38
+ Schema {
39
+ Columns { Name: "timestamp" Type: "Timestamp" NotNull: true }
40
+ Columns { Name: "data" Type: "Utf8" }
41
+ Columns { Name: "mess age" Type: "Utf8" }
42
+ KeyColumnNames: "timestamp"
43
+ }
44
+ }
45
+ )" ;
46
+
33
47
static const TString defaultTableSchema = R"(
34
48
Name: "ColumnTable"
35
49
ColumnShardCount: 1
@@ -45,7 +59,21 @@ static const TVector<NArrow::NTest::TTestColumn> defaultYdbSchema = {
45
59
NArrow::NTest::TTestColumn (" data" , TTypeInfo (NTypeIds::Utf8) )
46
60
};
47
61
48
- }}
62
+ static const TString tableSchemaFormat = R"(
63
+ Name: "TestTable"
64
+ Schema {
65
+ Columns {
66
+ Name: "Id"
67
+ Type: "Int32"
68
+ NotNull: True
69
+ }
70
+ Columns {
71
+ Name: "%s"
72
+ Type: "Utf8"
73
+ }
74
+ KeyColumnNames: ["Id"]
75
+ }
76
+ )" ;
49
77
50
78
#define DEBUG_HINT (TStringBuilder() << " at line " << __LINE__)
51
79
@@ -99,6 +127,7 @@ NKikimrTxDataShard::TEvPeriodicTableStats WaitTableStats(TTestActorRuntime& runt
99
127
100
128
return stats;
101
129
}
130
+ }}
102
131
103
132
Y_UNIT_TEST_SUITE (TOlap) {
104
133
Y_UNIT_TEST (CreateStore) {
@@ -1136,3 +1165,162 @@ Y_UNIT_TEST_SUITE(TOlap) {
1136
1165
CheckQuotaExceedance (runtime, TTestTxConfig::SchemeShard, " /MyRoot/SomeDatabase" , false , DEBUG_HINT);
1137
1166
}
1138
1167
}
1168
+
1169
+ Y_UNIT_TEST_SUITE (TOlapNaming) {
1170
+
1171
+ Y_UNIT_TEST (CreateColumnTableOk) {
1172
+ TTestBasicRuntime runtime;
1173
+ TTestEnv env (runtime);
1174
+ ui64 txId = 100 ;
1175
+
1176
+ TString allowedChars = " _-0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz" ;
1177
+
1178
+ TString tableSchema = Sprintf (tableSchemaFormat.c_str (), allowedChars.c_str ());
1179
+
1180
+ TestCreateColumnTable (runtime, ++txId, " /MyRoot" , tableSchema, {NKikimrScheme::StatusAccepted});
1181
+ env.TestWaitNotification (runtime, txId);
1182
+ }
1183
+
1184
+ Y_UNIT_TEST (CreateColumnTableFailed) {
1185
+ TTestBasicRuntime runtime;
1186
+ TTestEnv env (runtime);
1187
+ ui64 txId = 100 ;
1188
+
1189
+ TVector<TString> notAllowedNames = {" mess age" , " ~!@#$%^&*()+=asdfa" };
1190
+
1191
+ for (const auto & colName: notAllowedNames) {
1192
+ TString tableSchema = Sprintf (tableSchemaFormat.c_str (), colName.c_str ());
1193
+
1194
+ TestCreateColumnTable (runtime, ++txId, " /MyRoot" , tableSchema, {NKikimrScheme::StatusSchemeError});
1195
+ env.TestWaitNotification (runtime, txId);
1196
+ }
1197
+ }
1198
+
1199
+ Y_UNIT_TEST (CreateColumnStoreOk) {
1200
+ TTestBasicRuntime runtime;
1201
+ TTestEnv env (runtime);
1202
+ ui64 txId = 100 ;
1203
+
1204
+ const TString& storeSchema = defaultStoreSchema;
1205
+
1206
+ TestCreateOlapStore (runtime, ++txId, " /MyRoot" , storeSchema, {NKikimrScheme::StatusAccepted});
1207
+ env.TestWaitNotification (runtime, txId);
1208
+
1209
+ TestLs (runtime, " /MyRoot/OlapStore" , false , NLs::PathExist);
1210
+ }
1211
+
1212
+ Y_UNIT_TEST (CreateColumnStoreFailed) {
1213
+ TTestBasicRuntime runtime;
1214
+ TTestEnv env (runtime);
1215
+ ui64 txId = 100 ;
1216
+
1217
+ const TString& storeSchema = invalidStoreSchema;
1218
+
1219
+ TestCreateOlapStore (runtime, ++txId, " /MyRoot" , storeSchema, {NKikimrScheme::StatusSchemeError});
1220
+ env.TestWaitNotification (runtime, txId);
1221
+
1222
+ TestLs (runtime, " /MyRoot/OlapStore" , false , NLs::PathNotExist);
1223
+ }
1224
+
1225
+ Y_UNIT_TEST (AlterColumnTableOk) {
1226
+ TTestBasicRuntime runtime;
1227
+ TTestEnvOptions options;
1228
+ TTestEnv env (runtime, options);
1229
+ ui64 txId = 100 ;
1230
+
1231
+ TString tableSchema = Sprintf (tableSchemaFormat.c_str (), " message" );
1232
+
1233
+ TestCreateColumnTable (runtime, ++txId, " /MyRoot" , tableSchema, {NKikimrScheme::StatusAccepted});
1234
+ env.TestWaitNotification (runtime, txId);
1235
+
1236
+ TestAlterColumnTable (runtime, ++txId, " /MyRoot" , R"(
1237
+ Name: "TestTable"
1238
+ AlterSchema {
1239
+ AddColumns {
1240
+ Name: "NewColumn"
1241
+ Type: "Int32"
1242
+ }
1243
+ }
1244
+ )" );
1245
+ env.TestWaitNotification (runtime, txId);
1246
+ }
1247
+
1248
+ Y_UNIT_TEST (AlterColumnTableFailed) {
1249
+ TTestBasicRuntime runtime;
1250
+ TTestEnvOptions options;
1251
+ TTestEnv env (runtime, options);
1252
+ ui64 txId = 100 ;
1253
+
1254
+ TString tableSchema = Sprintf (tableSchemaFormat.c_str (), " message" );
1255
+
1256
+ TestCreateColumnTable (runtime, ++txId, " /MyRoot" , tableSchema, {NKikimrScheme::StatusAccepted});
1257
+ env.TestWaitNotification (runtime, txId);
1258
+
1259
+ TestAlterColumnTable (runtime, ++txId, " /MyRoot" , R"(
1260
+ Name: "TestTable"
1261
+ AlterSchema {
1262
+ AddColumns {
1263
+ Name: "New Column"
1264
+ Type: "Int32"
1265
+ }
1266
+ }
1267
+ )" , {NKikimrScheme::StatusSchemeError});
1268
+ env.TestWaitNotification (runtime, txId);
1269
+ }
1270
+
1271
+ Y_UNIT_TEST (AlterColumnStoreOk) {
1272
+ TTestBasicRuntime runtime;
1273
+ TTestEnv env (runtime);
1274
+ ui64 txId = 100 ;
1275
+
1276
+ const TString& olapSchema = defaultStoreSchema;
1277
+
1278
+ TestCreateOlapStore (runtime, ++txId, " /MyRoot" , olapSchema);
1279
+ env.TestWaitNotification (runtime, txId);
1280
+
1281
+ const TString& tableSchema = defaultTableSchema;
1282
+
1283
+ TestCreateColumnTable (runtime, ++txId, " /MyRoot/OlapStore" , tableSchema);
1284
+ env.TestWaitNotification (runtime, txId);
1285
+
1286
+ TestAlterOlapStore (runtime, ++txId, " /MyRoot" , R"(
1287
+ Name: "OlapStore"
1288
+ AlterSchemaPresets {
1289
+ Name: "default"
1290
+ AlterSchema {
1291
+ AddColumns { Name: "comment" Type: "Utf8" }
1292
+ }
1293
+ }
1294
+ )" , {NKikimrScheme::StatusAccepted});
1295
+
1296
+ env.TestWaitNotification (runtime, txId);
1297
+ }
1298
+
1299
+ Y_UNIT_TEST (AlterColumnStoreFailed) {
1300
+ TTestBasicRuntime runtime;
1301
+ TTestEnv env (runtime);
1302
+ ui64 txId = 100 ;
1303
+
1304
+ const TString& olapSchema = defaultStoreSchema;
1305
+
1306
+ TestCreateOlapStore (runtime, ++txId, " /MyRoot" , olapSchema);
1307
+ env.TestWaitNotification (runtime, txId);
1308
+
1309
+ const TString& tableSchema = defaultTableSchema;
1310
+
1311
+ TestCreateColumnTable (runtime, ++txId, " /MyRoot/OlapStore" , tableSchema);
1312
+ env.TestWaitNotification (runtime, txId);
1313
+
1314
+ TestAlterOlapStore (runtime, ++txId, " /MyRoot" , R"(
1315
+ Name: "OlapStore"
1316
+ AlterSchemaPresets {
1317
+ Name: "default"
1318
+ AlterSchema {
1319
+ AddColumns { Name: "mess age" Type: "Utf8" }
1320
+ }
1321
+ }
1322
+ )" , {NKikimrScheme::StatusSchemeError});
1323
+
1324
+ env.TestWaitNotification (runtime, txId);
1325
+ }
1326
+ }
0 commit comments