In the below code, language filter condition is optional whether it may contains data or null. If it contains null means dynamodb throws some error. How to overcome this ?
Map<String,String> expressionAttributesNames = new HashMap<>(); expressionAttributesNames.put("#Language", "Language");
Map<String,AttributeValue> expressionAttributeValues = new HashMap<>();
//expressionAttributeValues.put(":type", new AttributeValue().withS("test1"));
expressionAttributeValues.put(":name", new AttributeValue().withS("data part"));
//expressionAttributeValues.put(":key", new AttributeValue().withS("xxx yyy"));
expressionAttributeValues.put(":language", new AttributeValue().withS(null));
DynamoDBQueryExpression<Sample> queryExpression = new DynamoDBQueryExpression<Sample>()
.withKeyConditionExpression(keyConditionExpression)
.withExpressionAttributeNames(expressionAttributesNames)
.withExpressionAttributeValues(expressionAttributeValues)
.withFilterExpression("#Language = :language"); List<Sample> tools = mapper.query(Sample.class, queryExpression);
Exception is,
ExpressionAttributeValues contains invalid value: Supplied AttributeValue is empty, must contain exactly one of the supported datatypes for key :language (Service: AmazonDynamoDBv2; Status Code: 400; Error Code: ValidationException;