diff --git a/core/src/main/java/com/scalar/db/common/CoreError.java b/core/src/main/java/com/scalar/db/common/CoreError.java index e683f5ea6d..4137040b22 100644 --- a/core/src/main/java/com/scalar/db/common/CoreError.java +++ b/core/src/main/java/com/scalar/db/common/CoreError.java @@ -712,6 +712,30 @@ public enum CoreError implements ScalarDbError { "Db2 does not support renaming primary key or index key columns", "", ""), + DYNAMO_IMPORT_NOT_SUPPORTED( + Category.USER_ERROR, + "0223", + "Import-related functionality is not supported in DynamoDB", + "", + ""), + DYNAMO_PARTITION_KEY_BLOB_TYPE_NOT_SUPPORTED( + Category.USER_ERROR, + "0224", + "The BLOB type is supported only for the last column in the partition key in DynamoDB. Column: %s", + "", + ""), + DYNAMO_CLUSTERING_KEY_BLOB_TYPE_NOT_SUPPORTED( + Category.USER_ERROR, + "0225", + "The BLOB type is not supported for clustering keys in DynamoDB. Column: %s", + "", + ""), + DYNAMO_INDEX_COLUMN_BOOLEAN_TYPE_NOT_SUPPORTED( + Category.USER_ERROR, + "0226", + "The BOOLEAN type is not supported for index columns in DynamoDB. Column: %s", + "", + ""), // // Errors for the concurrency error category diff --git a/core/src/main/java/com/scalar/db/storage/dynamo/DynamoAdmin.java b/core/src/main/java/com/scalar/db/storage/dynamo/DynamoAdmin.java index 4376513655..7415af3516 100644 --- a/core/src/main/java/com/scalar/db/storage/dynamo/DynamoAdmin.java +++ b/core/src/main/java/com/scalar/db/storage/dynamo/DynamoAdmin.java @@ -285,24 +285,23 @@ private void checkMetadata(TableMetadata metadata) { } if (metadata.getColumnDataType(partitionKeyName) == DataType.BLOB) { throw new IllegalArgumentException( - "BLOB type is supported only for the last column in partition key in DynamoDB: " - + partitionKeyName); + CoreError.DYNAMO_PARTITION_KEY_BLOB_TYPE_NOT_SUPPORTED.buildMessage(partitionKeyName)); } } for (String clusteringKeyName : metadata.getClusteringKeyNames()) { if (metadata.getColumnDataType(clusteringKeyName) == DataType.BLOB) { throw new IllegalArgumentException( - "Currently, BLOB type is not supported for clustering keys in DynamoDB: " - + clusteringKeyName); + CoreError.DYNAMO_CLUSTERING_KEY_BLOB_TYPE_NOT_SUPPORTED.buildMessage( + clusteringKeyName)); } } for (String secondaryIndexName : metadata.getSecondaryIndexNames()) { if (metadata.getColumnDataType(secondaryIndexName) == DataType.BOOLEAN) { throw new IllegalArgumentException( - "Currently, BOOLEAN type is not supported for a secondary index in DynamoDB: " - + secondaryIndexName); + CoreError.DYNAMO_INDEX_COLUMN_BOOLEAN_TYPE_NOT_SUPPORTED.buildMessage( + secondaryIndexName)); } } } @@ -814,16 +813,11 @@ public void createIndex( throws ExecutionException { Namespace namespace = Namespace.of(namespacePrefix, nonPrefixedNamespace); TableMetadata metadata = getTableMetadata(nonPrefixedNamespace, table); - - if (metadata == null) { - throw new IllegalArgumentException( - "Table " + getFullTableName(namespace, table) + " does not exist"); - } + assert metadata != null; if (metadata.getColumnDataType(columnName) == DataType.BOOLEAN) { throw new IllegalArgumentException( - "Currently, BOOLEAN type is not supported for a secondary index in DynamoDB: " - + columnName); + CoreError.DYNAMO_INDEX_COLUMN_BOOLEAN_TYPE_NOT_SUPPORTED.buildMessage(columnName)); } long ru = Long.parseLong(options.getOrDefault(REQUEST_UNIT, DEFAULT_REQUEST_UNIT)); @@ -1259,15 +1253,13 @@ public void renameColumn( @Override public TableMetadata getImportTableMetadata( String namespace, String table, Map overrideColumnsType) { - throw new UnsupportedOperationException( - "Import-related functionality is not supported in DynamoDB"); + throw new UnsupportedOperationException(CoreError.DYNAMO_IMPORT_NOT_SUPPORTED.buildMessage()); } @Override public void addRawColumnToTable( String namespace, String table, String columnName, DataType columnType) { - throw new UnsupportedOperationException( - "Import-related functionality is not supported in DynamoDB"); + throw new UnsupportedOperationException(CoreError.DYNAMO_IMPORT_NOT_SUPPORTED.buildMessage()); } @Override @@ -1276,8 +1268,7 @@ public void importTable( String table, Map options, Map overrideColumnsType) { - throw new UnsupportedOperationException( - "Import-related functionality is not supported in DynamoDB"); + throw new UnsupportedOperationException(CoreError.DYNAMO_IMPORT_NOT_SUPPORTED.buildMessage()); } @Override