Skip to content

Commit 66d2bfd

Browse files
fix text & update CHANGELOG.md
1 parent 5800199 commit 66d2bfd

File tree

3 files changed

+50
-17
lines changed

3 files changed

+50
-17
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
* Table: AlterTable supports index renaming
2+
13
## 2.3.20 ##
24
* Table: Fixed session status updating on stream calls
35
* Core: Added endpoint pessimization when CreateSession returns OVERLOADED

table/pom.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@
5151
<environmentVariables>
5252
<TESTCONTAINERS_REUSE_ENABLE>true</TESTCONTAINERS_REUSE_ENABLE>
5353
<YDB_DOCKER_IMAGE>ydbplatform/local-ydb:trunk</YDB_DOCKER_IMAGE>
54+
<YDB_FEATURE_FLAGS>enable_vector_index</YDB_FEATURE_FLAGS>
5455
</environmentVariables>
5556
</configuration>
5657
</plugin>

table/src/test/java/tech/ydb/table/integration/AlterTableTest.java

Lines changed: 47 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -143,20 +143,6 @@ public void alterTableTest() {
143143

144144
Assert.assertEquals(1, description.getIndexes().size());
145145
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"));
160146
}
161147

162148
@Test
@@ -177,7 +163,7 @@ public void alterTableWithSerialTest() {
177163
Assert.assertTrue("Create table with indexes " + createStatus, createStatus.isSuccess());
178164

179165
// --------------------- 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();
181167
Assert.assertTrue("Describe table with indexes " + describeResult.getStatus(), describeResult.isSuccess());
182168

183169
TableDescription description = describeResult.getValue();
@@ -207,7 +193,7 @@ public void alterTableWithSerialTest() {
207193
Assert.assertTrue("Alter table with column " + alterStatus, alterStatus.isSuccess());
208194

209195
// --------------------- describe table after first altering -----------------------------
210-
describeResult = ctx.supplyResult(session ->session.describeTable(tablePath)).join();
196+
describeResult = ctx.supplyResult(session -> session.describeTable(tablePath)).join();
211197
Assert.assertTrue("Describe table after altering " + describeResult.getStatus(), describeResult.isSuccess());
212198

213199
description = describeResult.getValue();
@@ -234,7 +220,7 @@ public void alterTableWithSerialTest() {
234220
Assert.assertTrue("Alter table with indexes " + alterStatus, alterStatus.isSuccess());
235221

236222
// --------------------- describe table after first altering -----------------------------
237-
describeResult = ctx.supplyResult(session ->session.describeTable(tablePath)).join();
223+
describeResult = ctx.supplyResult(session -> session.describeTable(tablePath)).join();
238224
Assert.assertTrue("Describe table after altering " + describeResult.getStatus(), describeResult.isSuccess());
239225

240226
description = describeResult.getValue();
@@ -253,6 +239,50 @@ public void alterTableWithSerialTest() {
253239
assertIndexAsync(description.getIndexes().get(0), "idx2", Collections.singletonList("data"), Collections.singletonList("code"));
254240
}
255241

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+
256286
private void assertColumn(TableColumn column, String name, Type type) {
257287
assertColumn(column, name, type, false, false);
258288
}

0 commit comments

Comments
 (0)