There are several articles on how to throw constraint validation exception (ex: DynamoDBMapper save only if object doesn't exist) on if the hash key is duplicate or matching your criteria, was wondering if the same applies to range key.
I tested locally and it does not throw error.
My save expression logic is as below
DynamoDBSaveExpression saveExpression = new DynamoDBSaveExpression();
Map<String, ExpectedAttributeValue> expectedAttributes =
ImmutableMap.<String, ExpectedAttributeValue>builder()
.put("range-key-column",
new ExpectedAttributeValue().withExists(false))
.build();
saveExpression.setExpected(expectedAttributes);