*/
private static boolean tableHasCorrectSchema(AmazonDynamoDBClient client, String tableName, String key) {
DescribeTableRequest describeTableRequest = new DescribeTableRequest();
describeTableRequest.setTableName(tableName);
DescribeTableResult describeTableResult = client.describeTable(describeTableRequest);
TableDescription tableDescription = describeTableResult.getTable();
if (tableDescription.getAttributeDefinitions().size() != 1) {
LOG.error("The number of attribute definitions does not match the existing table.");
return false;
}
AttributeDefinition attributeDefinition = tableDescription.getAttributeDefinitions().get(0);
if (!attributeDefinition.getAttributeName().equals(key)
|| !attributeDefinition.getAttributeType().equals(ScalarAttributeType.S.toString())) {
LOG.error("Attribute name or type does not match existing table.");
return false;
}
List<KeySchemaElement> KSEs = tableDescription.getKeySchema();
if (KSEs.size() != 1) {
LOG.error("The number of key schema elements does not match the existing table.");
return false;
}
KeySchemaElement kse = KSEs.get(0);