@@ -143,20 +143,6 @@ public void alterTableTest() {
143
143
144
144
Assert .assertEquals (1 , description .getIndexes ().size ());
145
145
assertIndexAsync (description .getIndexes ().get (0 ), "idx2" , Collections .singletonList ("data" ), Collections .singletonList ("code" ));
146
-
147
- // // --------------------- alter table with rename indexes -----------------------------
148
- // alterStatus = ctx.supplyStatus(
149
- // session -> session.alterTable(tablePath, new AlterTableSettings()
150
- // .addRenameIndex("idx2", "new_name"))
151
- // ).join();
152
- // Assert.assertTrue("Alter table with rename indexes " + alterStatus, alterStatus.isSuccess());
153
- //
154
- // // --------------------- describe table after rename indexes altering -----------------------------
155
- // describeResult = ctx.supplyResult(session -> session.describeTable(tablePath)).join();
156
- // Assert.assertTrue("Describe table after altering " + describeResult.getStatus(), describeResult.isSuccess());
157
- //
158
- // Assert.assertEquals(1, description.getIndexes().size());
159
- // assertIndexAsync(description.getIndexes().get(0), "new_name", Arrays.asList("data"), Arrays.asList("code"));
160
146
}
161
147
162
148
@ Test
@@ -177,7 +163,7 @@ public void alterTableWithSerialTest() {
177
163
Assert .assertTrue ("Create table with indexes " + createStatus , createStatus .isSuccess ());
178
164
179
165
// --------------------- describe table after creating -----------------------------
180
- Result <TableDescription > describeResult = ctx .supplyResult (session ->session .describeTable (tablePath )).join ();
166
+ Result <TableDescription > describeResult = ctx .supplyResult (session -> session .describeTable (tablePath )).join ();
181
167
Assert .assertTrue ("Describe table with indexes " + describeResult .getStatus (), describeResult .isSuccess ());
182
168
183
169
TableDescription description = describeResult .getValue ();
@@ -207,7 +193,7 @@ public void alterTableWithSerialTest() {
207
193
Assert .assertTrue ("Alter table with column " + alterStatus , alterStatus .isSuccess ());
208
194
209
195
// --------------------- describe table after first altering -----------------------------
210
- describeResult = ctx .supplyResult (session ->session .describeTable (tablePath )).join ();
196
+ describeResult = ctx .supplyResult (session -> session .describeTable (tablePath )).join ();
211
197
Assert .assertTrue ("Describe table after altering " + describeResult .getStatus (), describeResult .isSuccess ());
212
198
213
199
description = describeResult .getValue ();
@@ -234,7 +220,7 @@ public void alterTableWithSerialTest() {
234
220
Assert .assertTrue ("Alter table with indexes " + alterStatus , alterStatus .isSuccess ());
235
221
236
222
// --------------------- describe table after first altering -----------------------------
237
- describeResult = ctx .supplyResult (session ->session .describeTable (tablePath )).join ();
223
+ describeResult = ctx .supplyResult (session -> session .describeTable (tablePath )).join ();
238
224
Assert .assertTrue ("Describe table after altering " + describeResult .getStatus (), describeResult .isSuccess ());
239
225
240
226
description = describeResult .getValue ();
@@ -253,6 +239,50 @@ public void alterTableWithSerialTest() {
253
239
assertIndexAsync (description .getIndexes ().get (0 ), "idx2" , Collections .singletonList ("data" ), Collections .singletonList ("code" ));
254
240
}
255
241
242
+ @ Test
243
+ public void renameIndexTest () {
244
+ // --------------------- create table -----------------------------
245
+ ctx .supplyStatus (session -> session .executeSchemeQuery (""
246
+ + "CREATE TABLE " + TABLE_NAME + " ("
247
+ + " id Uint64 NOT NULL,"
248
+ + " code Text NOT NULL,"
249
+ + " size Float,"
250
+ + " created Timestamp,"
251
+ + " data Text,"
252
+ + " PRIMARY KEY(id),"
253
+ + " INDEX idx1 GLOBAL ON (id, code),"
254
+ + " INDEX idx2 GLOBAL ASYNC ON (data) COVER (code)"
255
+ + ")"
256
+ )).join ().expectSuccess ();
257
+
258
+ Status alterStatus = ctx .supplyStatus (
259
+ session -> session .alterTable (tablePath , new AlterTableSettings ()
260
+ .addRenameIndex ("idx1" , "new_name" ))
261
+ ).join ();
262
+ Assert .assertTrue ("Alter table with rename indexes " + alterStatus , alterStatus .isSuccess ());
263
+
264
+ Result <TableDescription > describeResult = ctx .supplyResult (session -> session .describeTable (tablePath )).join ();
265
+ Assert .assertTrue ("Describe table after altering " + describeResult .getStatus (), describeResult .isSuccess ());
266
+
267
+ TableDescription description = describeResult .getValue ();
268
+ Assert .assertEquals (2 , description .getIndexes ().size ());
269
+ assertIndexSync (description .getIndexes ().get (1 ), "new_name" , Arrays .asList ("id" , "code" ), Collections .emptyList ());
270
+
271
+ alterStatus = ctx .supplyStatus (
272
+ session -> session .alterTable (tablePath , new AlterTableSettings ()
273
+ .addRenameIndex ("new_name" , "idx2" , true ))
274
+ ).join ();
275
+ Assert .assertTrue ("Alter table with rename indexes " + alterStatus , alterStatus .isSuccess ());
276
+
277
+ describeResult = ctx .supplyResult (session -> session .describeTable (tablePath )).join ();
278
+ Assert .assertTrue ("Describe table after altering " + describeResult .getStatus (), describeResult .isSuccess ());
279
+
280
+ description = describeResult .getValue ();
281
+
282
+ Assert .assertEquals (1 , description .getIndexes ().size ());
283
+ assertIndexSync (description .getIndexes ().get (0 ), "idx2" , Arrays .asList ("id" , "code" ), Collections .emptyList ());
284
+ }
285
+
256
286
private void assertColumn (TableColumn column , String name , Type type ) {
257
287
assertColumn (column , name , type , false , false );
258
288
}
0 commit comments