Skip to content

Commit 600c743

Browse files
committed
Revisit importTable() in Consensus Commit
1 parent ddc8d74 commit 600c743

File tree

21 files changed

+35
-418
lines changed

21 files changed

+35
-418
lines changed

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

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -126,16 +126,6 @@ protected void waitForTableDeletion() {
126126
}
127127
}
128128

129-
@Test
130-
@Override
131-
@Disabled("Import-related functionality is not supported in Cassandra")
132-
public void getImportTableMetadata_WithSufficientPermission_ShouldSucceed() {}
133-
134-
@Test
135-
@Override
136-
@Disabled("Import-related functionality is not supported in Cassandra")
137-
public void addRawColumnToTable_WithSufficientPermission_ShouldSucceed() {}
138-
139129
@Test
140130
@Override
141131
@Disabled("Import-related functionality is not supported in Cassandra")

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

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -45,16 +45,6 @@ protected void sleepBetweenTests() {
4545
Uninterruptibles.sleepUninterruptibly(SLEEP_BETWEEN_TESTS_SECONDS, TimeUnit.SECONDS);
4646
}
4747

48-
@Test
49-
@Override
50-
@Disabled("Import-related functionality is not supported in DynamoDB")
51-
public void getImportTableMetadata_WithSufficientPermission_ShouldSucceed() {}
52-
53-
@Test
54-
@Override
55-
@Disabled("Import-related functionality is not supported in DynamoDB")
56-
public void addRawColumnToTable_WithSufficientPermission_ShouldSucceed() {}
57-
5848
@Test
5949
@Override
6050
@Disabled("Import-related functionality is not supported in DynamoDB")

core/src/integration-test/java/com/scalar/db/storage/jdbc/JdbcSchemaLoaderImportIntegrationTest.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
import java.util.Map;
1111
import java.util.Properties;
1212
import java.util.concurrent.TimeUnit;
13+
import org.junit.jupiter.api.AfterAll;
1314
import org.junit.jupiter.api.Test;
1415
import org.junit.jupiter.api.condition.DisabledIf;
1516
import org.slf4j.Logger;
@@ -191,6 +192,7 @@ public void importTables_ImportableTablesAndNonRelatedSameNameTableGiven_ShouldI
191192
super.importTables_ImportableTablesAndNonRelatedSameNameTableGiven_ShouldImportProperly();
192193
}
193194

195+
@AfterAll
194196
@Override
195197
public void afterAll() {
196198
try {

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

Lines changed: 0 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
11
package com.scalar.db.api;
22

33
import com.scalar.db.exception.storage.ExecutionException;
4-
import com.scalar.db.io.DataType;
5-
import java.util.Collections;
6-
import java.util.Map;
74

85
/**
96
* An administrative interface for distributed storage implementations. The user can execute
@@ -44,50 +41,6 @@
4441
*/
4542
public interface DistributedStorageAdmin extends Admin, AutoCloseable {
4643

47-
/**
48-
* Get import table metadata in the ScalarDB format.
49-
*
50-
* @param namespace namespace name of import table
51-
* @param table import table name
52-
* @throws IllegalArgumentException if the table does not exist
53-
* @throws IllegalStateException if the table does not meet the requirement of ScalarDB table
54-
* @throws ExecutionException if the operation fails
55-
* @return import table metadata in the ScalarDB format
56-
*/
57-
default TableMetadata getImportTableMetadata(String namespace, String table)
58-
throws ExecutionException {
59-
return getImportTableMetadata(namespace, table, Collections.emptyMap());
60-
}
61-
62-
/**
63-
* Get import table metadata in the ScalarDB format.
64-
*
65-
* @param namespace namespace name of import table
66-
* @param table import table name
67-
* @param overrideColumnsType a map of column data type by column name. Only set the column for
68-
* which you want to override the default data type mapping.
69-
* @throws IllegalArgumentException if the table does not exist
70-
* @throws IllegalStateException if the table does not meet the requirement of ScalarDB table
71-
* @throws ExecutionException if the operation fails
72-
* @return import table metadata in the ScalarDB format
73-
*/
74-
TableMetadata getImportTableMetadata(
75-
String namespace, String table, Map<String, DataType> overrideColumnsType)
76-
throws ExecutionException;
77-
78-
/**
79-
* Add a column in the table without updating the metadata table in ScalarDB.
80-
*
81-
* @param namespace namespace name of import table
82-
* @param table import table name
83-
* @param columnName name of the column to be added
84-
* @param columnType type of the column to be added
85-
* @throws IllegalArgumentException if the table does not exist
86-
* @throws ExecutionException if the operation fails
87-
*/
88-
void addRawColumnToTable(String namespace, String table, String columnName, DataType columnType)
89-
throws ExecutionException;
90-
9144
/**
9245
* Returns the storage information.
9346
*

core/src/main/java/com/scalar/db/common/CommonDistributedStorageAdmin.java

Lines changed: 0 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -451,20 +451,6 @@ public Set<String> getNamespaceNames() throws ExecutionException {
451451
}
452452
}
453453

454-
@Override
455-
public TableMetadata getImportTableMetadata(
456-
String namespace, String table, Map<String, DataType> overrideColumnsType)
457-
throws ExecutionException {
458-
try {
459-
return admin.getImportTableMetadata(namespace, table, overrideColumnsType);
460-
} catch (ExecutionException e) {
461-
throw new ExecutionException(
462-
CoreError.GETTING_IMPORT_TABLE_METADATA_FAILED.buildMessage(
463-
ScalarDbUtils.getFullTableName(namespace, table)),
464-
e);
465-
}
466-
}
467-
468454
@Override
469455
public void importTable(
470456
String namespace,
@@ -489,20 +475,6 @@ public void importTable(
489475
}
490476
}
491477

492-
@Override
493-
public void addRawColumnToTable(
494-
String namespace, String table, String columnName, DataType columnType)
495-
throws ExecutionException {
496-
try {
497-
admin.addRawColumnToTable(namespace, table, columnName, columnType);
498-
} catch (ExecutionException e) {
499-
throw new ExecutionException(
500-
CoreError.ADDING_RAW_COLUMN_TO_TABLE_FAILED.buildMessage(
501-
ScalarDbUtils.getFullTableName(namespace, table), columnName, columnType),
502-
e);
503-
}
504-
}
505-
506478
@Override
507479
public void upgrade(Map<String, String> options) throws ExecutionException {
508480
try {

core/src/main/java/com/scalar/db/service/AdminService.java

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -120,20 +120,6 @@ public void renameTable(String namespace, String oldTableName, String newTableNa
120120
admin.renameTable(namespace, oldTableName, newTableName);
121121
}
122122

123-
@Override
124-
public TableMetadata getImportTableMetadata(
125-
String namespace, String table, Map<String, DataType> overrideColumnsType)
126-
throws ExecutionException {
127-
return admin.getImportTableMetadata(namespace, table, overrideColumnsType);
128-
}
129-
130-
@Override
131-
public void addRawColumnToTable(
132-
String namespace, String table, String columnName, DataType columnType)
133-
throws ExecutionException {
134-
admin.addRawColumnToTable(namespace, table, columnName, columnType);
135-
}
136-
137123
@Override
138124
public void importTable(
139125
String namespace,

core/src/main/java/com/scalar/db/storage/cassandra/CassandraAdmin.java

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -285,20 +285,6 @@ private TableMetadata createTableMetadata(com.datastax.driver.core.TableMetadata
285285
return builder.build();
286286
}
287287

288-
@Override
289-
public TableMetadata getImportTableMetadata(
290-
String namespace, String table, Map<String, DataType> overrideColumnsType) {
291-
throw new UnsupportedOperationException(
292-
CoreError.CASSANDRA_IMPORT_NOT_SUPPORTED.buildMessage());
293-
}
294-
295-
@Override
296-
public void addRawColumnToTable(
297-
String namespace, String table, String columnName, DataType columnType) {
298-
throw new UnsupportedOperationException(
299-
CoreError.CASSANDRA_IMPORT_NOT_SUPPORTED.buildMessage());
300-
}
301-
302288
@Override
303289
public void importTable(
304290
String namespace,

core/src/main/java/com/scalar/db/storage/cosmos/CosmosAdmin.java

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -674,18 +674,6 @@ public void renameTable(String namespace, String oldTableName, String newTableNa
674674
CoreError.COSMOS_RENAME_TABLE_NOT_SUPPORTED.buildMessage());
675675
}
676676

677-
@Override
678-
public TableMetadata getImportTableMetadata(
679-
String namespace, String table, Map<String, DataType> overrideColumnsType) {
680-
throw new UnsupportedOperationException(CoreError.COSMOS_IMPORT_NOT_SUPPORTED.buildMessage());
681-
}
682-
683-
@Override
684-
public void addRawColumnToTable(
685-
String namespace, String table, String columnName, DataType columnType) {
686-
throw new UnsupportedOperationException(CoreError.COSMOS_IMPORT_NOT_SUPPORTED.buildMessage());
687-
}
688-
689677
@Override
690678
public void importTable(
691679
String namespace,

core/src/main/java/com/scalar/db/storage/dynamo/DynamoAdmin.java

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1466,18 +1466,6 @@ public void renameTable(String namespace, String oldTableName, String newTableNa
14661466
CoreError.DYNAMO_RENAME_TABLE_NOT_SUPPORTED.buildMessage());
14671467
}
14681468

1469-
@Override
1470-
public TableMetadata getImportTableMetadata(
1471-
String namespace, String table, Map<String, DataType> overrideColumnsType) {
1472-
throw new UnsupportedOperationException(CoreError.DYNAMO_IMPORT_NOT_SUPPORTED.buildMessage());
1473-
}
1474-
1475-
@Override
1476-
public void addRawColumnToTable(
1477-
String namespace, String table, String columnName, DataType columnType) {
1478-
throw new UnsupportedOperationException(CoreError.DYNAMO_IMPORT_NOT_SUPPORTED.buildMessage());
1479-
}
1480-
14811469
@Override
14821470
public void importTable(
14831471
String namespace,

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

Lines changed: 2 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -565,8 +565,8 @@ public TableMetadata getTableMetadata(String namespace, String table) throws Exe
565565
return builder.build();
566566
}
567567

568-
@Override
569-
public TableMetadata getImportTableMetadata(
568+
@VisibleForTesting
569+
TableMetadata getImportTableMetadata(
570570
String namespace, String table, Map<String, DataType> overrideColumnsType)
571571
throws ExecutionException {
572572
TableMetadata.Builder builder = TableMetadata.newBuilder();
@@ -1036,34 +1036,6 @@ public void renameTable(String namespace, String oldTableName, String newTableNa
10361036
}
10371037
}
10381038

1039-
@Override
1040-
public void addRawColumnToTable(
1041-
String namespace, String table, String columnName, DataType columnType)
1042-
throws ExecutionException {
1043-
try (Connection connection = dataSource.getConnection()) {
1044-
if (!tableExistsInternal(connection, namespace, table)) {
1045-
throw new IllegalArgumentException(
1046-
CoreError.TABLE_NOT_FOUND.buildMessage(getFullTableName(namespace, table)));
1047-
}
1048-
1049-
String addNewColumnStatement =
1050-
"ALTER TABLE "
1051-
+ encloseFullTableName(namespace, table)
1052-
+ " ADD "
1053-
+ enclose(columnName)
1054-
+ " "
1055-
+ rdbEngine.getDataTypeForEngine(columnType);
1056-
1057-
execute(connection, addNewColumnStatement);
1058-
} catch (SQLException e) {
1059-
throw new ExecutionException(
1060-
String.format(
1061-
"Adding the new %s column to the %s table failed",
1062-
columnName, getFullTableName(namespace, table)),
1063-
e);
1064-
}
1065-
}
1066-
10671039
@VisibleForTesting
10681040
void createIndex(
10691041
Connection connection, String schema, String table, String indexedColumn, boolean ifNotExists)

0 commit comments

Comments
 (0)