- Newest
- Most votes
- Most comments
When using DynamoDB's FilterExpression in a Scan operation with the AWS SDK for Java v2, the behavior for attribute name or type mismatches is as follows:
For attribute names that don't exist in the table items:
- The Scan operation will not raise an exception
- Items that don't have the specified attribute will be filtered out
- If no items match the criteria due to missing attributes, you'll get an empty result set with Count=0
For type mismatches between the FilterExpression and the actual attribute types in the table:
- The Scan operation will not raise an exception for type mismatches
- Items with mismatched types will be filtered out from the results
- The operation will complete successfully, but may return fewer or no items
In your specific example with "StudentID (Number) < 500000 AND isGraduated (Boolean) is False":
- If StudentID is actually a String in the table, those items won't match the numeric comparison
- If isGraduated doesn't exist in any items, those items won't match that condition
- Due to the AND operator, no items would match both conditions, resulting in an empty result set
The Scan operation will still return metadata like ScannedCount (showing how many items were examined) even if Count=0 (showing how many items passed the filter). This is normal behavior as FilterExpressions are applied after items are read but before they're returned to you.
Sources
DynamoDbClient (AWS SDK for Java - 2.21.29)
Scan - Amazon DynamoDB
ScanFilter (legacy) - Amazon DynamoDB
DynamoDbAsyncClient (AWS SDK for Java - 2.21.29)
Relevant content
asked 3 years ago
asked 2 years ago
- AWS OFFICIALUpdated 2 years ago
