- Newest
- Most votes
- Most comments
Hello,
Thank you for your post.
I am sharing the answer provided by my colleague on your question. Please review it below:
The "AttributeUpdates" API of DynamoDB accept only string value types for the N parameter[1] This will explain justify the error message observed.
Numbers are sent across the network to DynamoDB as strings, to maximize compatibility across languages and libraries. However, DynamoDB treats them as number type attributes for mathematical operations[2]. With this in mind I think your implemented workaround sounds good. Hope this explains your observation, meanwhile do not hesitate to contact us if you have any additional questions or concerns.
References:
[1] https://docs.aws.amazon.com/amazondynamodb/latest/APIReference/API_UpdateItem.html
[2] https://docs.aws.amazon.com/amazondynamodb/latest/APIReference/API_AttributeValue.html#DDB-Type-AttributeValue-N
Thank you for the response. FYI, I've determined that this is also a problem in step-functions when feeding the numeric results of a dynamodb getItem task into a Choice state: I cannot utilize any of the numeric comparison functions successfully; however, the string comparison operators do function as expected.
The root cause appears to be that the results for the numeric fields from dynamodb are being output from the getItem task as strings. Maybe this is something that can be addressed in an upcoming release? (Hopefully before too many people build convoluted work-arounds)
Relevant content
- asked 2 years ago
- asked 9 months ago
- AWS OFFICIALUpdated 2 years ago
- AWS OFFICIALUpdated 2 years ago
- AWS OFFICIALUpdated a year ago
- AWS OFFICIALUpdated 3 months ago