Skip to content

Commit 7a3f6d7

Browse files
committed
Fix
1 parent 12885d2 commit 7a3f6d7

File tree

7 files changed

+28
-18
lines changed

7 files changed

+28
-18
lines changed

core/src/integration-test/java/com/scalar/db/storage/cassandra/CassandraAdminPermissionIntegrationTest.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,4 +153,9 @@ public void renameColumn_WithSufficientPermission_ShouldSucceed() throws Executi
153153
assertThatCode(() -> adminForNormalUser.renameColumn(NAMESPACE, TABLE, COL_NAME1, NEW_COL_NAME))
154154
.doesNotThrowAnyException();
155155
}
156+
157+
@Test
158+
@Override
159+
@Disabled("Cassandra does not support renaming tables")
160+
public void renameTable_WithSufficientPermission_ShouldSucceed() {}
156161
}

core/src/integration-test/java/com/scalar/db/storage/dynamo/DynamoAdminPermissionIntegrationTest.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,4 +69,9 @@ public void dropColumnFromTable_WithSufficientPermission_ShouldSucceed() {}
6969
@Override
7070
@Disabled("DynamoDB does not support renaming columns")
7171
public void renameColumn_WithSufficientPermission_ShouldSucceed() {}
72+
73+
@Test
74+
@Override
75+
@Disabled("DynamoDB does not support renaming columns")
76+
public void renameTable_WithSufficientPermission_ShouldSucceed() {}
7277
}

core/src/main/java/com/scalar/db/api/Admin.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -540,8 +540,8 @@ void renameColumn(String namespace, String table, String oldColumnName, String n
540540
* @param namespace the table namespace
541541
* @param oldTableName the current name of the table to rename
542542
* @param newTableName the new name of the table
543-
* @throws IllegalArgumentException if the table to rename does not exist or the new table already
544-
* exists
543+
* @throws IllegalArgumentException if the table to rename does not exist or the table with the
544+
* new name already exists
545545
* @throws ExecutionException if the operation fails
546546
*/
547547
void renameTable(String namespace, String oldTableName, String newTableName)

core/src/main/java/com/scalar/db/storage/jdbc/RdbEngineSqlServer.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ public String renameColumnSql(
113113
+ "."
114114
+ enclose(oldColumnName)
115115
+ "', '"
116-
+ enclose(newColumnName)
116+
+ newColumnName
117117
+ "', 'COLUMN'";
118118
}
119119

@@ -122,7 +122,7 @@ public String renameTableSql(String namespace, String oldTableName, String newTa
122122
return "EXEC sp_rename '"
123123
+ encloseFullTableName(namespace, oldTableName)
124124
+ "', '"
125-
+ enclose(newTableName)
125+
+ newTableName
126126
+ "'";
127127
}
128128

core/src/test/java/com/scalar/db/storage/jdbc/JdbcAdminTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3143,7 +3143,7 @@ public void renameColumn_ForSqlServer_ShouldWorkProperly()
31433143
"SELECT [column_name],[data_type],[key_type],[clustering_order],[indexed] FROM ["
31443144
+ METADATA_SCHEMA
31453145
+ "].[metadata] WHERE [full_table_name]=? ORDER BY [ordinal_position] ASC",
3146-
"EXEC sp_rename '[ns].[table].[c2]', '[c3]', 'COLUMN'",
3146+
"EXEC sp_rename '[ns].[table].[c2]', 'c3', 'COLUMN'",
31473147
"DELETE FROM [" + METADATA_SCHEMA + "].[metadata] WHERE [full_table_name] = 'ns.table'",
31483148
"INSERT INTO ["
31493149
+ METADATA_SCHEMA
@@ -3297,7 +3297,7 @@ public void renameTable_ForSqlServer_ShouldWorkProperly()
32973297
"SELECT [column_name],[data_type],[key_type],[clustering_order],[indexed] FROM ["
32983298
+ METADATA_SCHEMA
32993299
+ "].[metadata] WHERE [full_table_name]=? ORDER BY [ordinal_position] ASC",
3300-
"EXEC sp_rename '[ns].[table]', '[table_new]'",
3300+
"EXEC sp_rename '[ns].[table]', 'table_new'",
33013301
"DELETE FROM [" + METADATA_SCHEMA + "].[metadata] WHERE [full_table_name] = 'ns.table'",
33023302
"INSERT INTO ["
33033303
+ METADATA_SCHEMA

integration-test/src/main/java/com/scalar/db/api/DistributedStorageAdminIntegrationTestBase.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1077,21 +1077,21 @@ public void renameTable_ForExistingTable_ShouldRenameTableCorrectly() throws Exe
10771077
try {
10781078
// Arrange
10791079
Map<String, String> options = getCreationOptions();
1080-
TableMetadata currentTableMetadata =
1080+
TableMetadata tableMetadata =
10811081
TableMetadata.newBuilder()
10821082
.addColumn(getColumnName1(), DataType.INT)
10831083
.addColumn(getColumnName2(), DataType.INT)
10841084
.addPartitionKey(getColumnName1())
10851085
.build();
1086-
admin.createTable(namespace1, getTable4(), currentTableMetadata, options);
1086+
admin.createTable(namespace1, getTable4(), tableMetadata, options);
10871087

10881088
// Act
10891089
admin.renameTable(namespace1, getTable4(), newTableName);
10901090

10911091
// Assert
10921092
assertThat(admin.tableExists(namespace1, getTable4())).isFalse();
10931093
assertThat(admin.tableExists(namespace1, newTableName)).isTrue();
1094-
assertThat(admin.getTableMetadata(namespace1, newTableName)).isEqualTo(currentTableMetadata);
1094+
assertThat(admin.getTableMetadata(namespace1, newTableName)).isEqualTo(tableMetadata);
10951095
} finally {
10961096
admin.dropTable(namespace1, getTable4(), true);
10971097
admin.dropTable(namespace1, newTableName, true);
@@ -1340,14 +1340,14 @@ public void renameTable_IfNewTableNameAlreadyExists_ShouldThrowIllegalArgumentEx
13401340
try {
13411341
// Arrange
13421342
Map<String, String> options = getCreationOptions();
1343-
TableMetadata currentTableMetadata =
1343+
TableMetadata tableMetadata =
13441344
TableMetadata.newBuilder()
13451345
.addColumn(getColumnName1(), DataType.INT)
13461346
.addColumn(getColumnName2(), DataType.INT)
13471347
.addPartitionKey(getColumnName1())
13481348
.build();
1349-
admin.createTable(namespace1, getTable4(), currentTableMetadata, options);
1350-
admin.createTable(namespace1, newTableName, currentTableMetadata, options);
1349+
admin.createTable(namespace1, getTable4(), tableMetadata, options);
1350+
admin.createTable(namespace1, newTableName, tableMetadata, options);
13511351

13521352
// Act Assert
13531353
assertThatThrownBy(() -> admin.renameTable(namespace1, getTable4(), newTableName))

integration-test/src/main/java/com/scalar/db/api/DistributedTransactionAdminIntegrationTestBase.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1166,21 +1166,21 @@ public void renameTable_ForExistingTable_ShouldRenameTableCorrectly() throws Exe
11661166
try {
11671167
// Arrange
11681168
Map<String, String> options = getCreationOptions();
1169-
TableMetadata currentTableMetadata =
1169+
TableMetadata tableMetadata =
11701170
TableMetadata.newBuilder()
11711171
.addColumn("c1", DataType.INT)
11721172
.addColumn("c2", DataType.INT)
11731173
.addPartitionKey("c1")
11741174
.build();
1175-
admin.createTable(namespace1, TABLE4, currentTableMetadata, options);
1175+
admin.createTable(namespace1, TABLE4, tableMetadata, options);
11761176

11771177
// Act
11781178
admin.renameTable(namespace1, TABLE4, newTableName);
11791179

11801180
// Assert
11811181
assertThat(admin.tableExists(namespace1, TABLE4)).isFalse();
11821182
assertThat(admin.tableExists(namespace1, newTableName)).isTrue();
1183-
assertThat(admin.getTableMetadata(namespace1, newTableName)).isEqualTo(currentTableMetadata);
1183+
assertThat(admin.getTableMetadata(namespace1, newTableName)).isEqualTo(tableMetadata);
11841184
} finally {
11851185
admin.dropTable(namespace1, TABLE4, true);
11861186
admin.dropTable(namespace1, newTableName, true);
@@ -1203,14 +1203,14 @@ public void renameTable_IfNewTableNameAlreadyExists_ShouldThrowIllegalArgumentEx
12031203
try {
12041204
// Arrange
12051205
Map<String, String> options = getCreationOptions();
1206-
TableMetadata currentTableMetadata =
1206+
TableMetadata tableMetadata =
12071207
TableMetadata.newBuilder()
12081208
.addColumn("c1", DataType.INT)
12091209
.addColumn("c2", DataType.INT)
12101210
.addPartitionKey("c1")
12111211
.build();
1212-
admin.createTable(namespace1, TABLE4, currentTableMetadata, options);
1213-
admin.createTable(namespace1, newTableName, currentTableMetadata, options);
1212+
admin.createTable(namespace1, TABLE4, tableMetadata, options);
1213+
admin.createTable(namespace1, newTableName, tableMetadata, options);
12141214

12151215
// Act Assert
12161216
assertThatThrownBy(() -> admin.renameTable(namespace1, TABLE4, newTableName))

0 commit comments

Comments
 (0)