When trying to do a delete via AWS Java SDK I get the error
The provided key element does not match the schema (Service: AmazonDynamoDBv2; Status Code: 400; Error Code: ValidationException; Request ID: 52N303HS3D535K28KSN3R3803VVV4KQNSO5AEMVJF66Q9ASUAAJG)
I have a delete item spec defined that looks like this
DeleteItemSpec deleteItemSpec = new DeleteItemSpec()
.withPrimaryKey("pk", messageId)
.withConditionExpression("#ip > :val")
.withNameMap(new NameMap()
.with("#ip", "timestamp"))
.withValueMap(new ValueMap()
.withNumber(":val", 0))
.withReturnValues(ReturnValue.NONE);
And my table is created like this
List<AttributeDefinition> attributeDefinitions = new ArrayList<>();
attributeDefinitions.add(new AttributeDefinition()
.withAttributeName("pk")
.withAttributeType(ScalarAttributeType.S));
attributeDefinitions.add(new AttributeDefinition()
.withAttributeName("timestamp")
.withAttributeType(ScalarAttributeType.N));
List<KeySchemaElement> keySchema = new ArrayList<>();
keySchema.add(new KeySchemaElement()
.withAttributeName("pk")
.withKeyType(KeyType.HASH));
keySchema.add(new KeySchemaElement()
.withAttributeName("timestamp")
.withKeyType(KeyType.RANGE));
I'm wondering if the sort key for timestamp is causing this issue. Do I need to specify the timestamp other than > 0?