Add support to pass in variables to the DynamoDB Enchanced Client Extensions
- Dominant language
- Java
- Stars
- 2.6k
- Forks
- 1k
- Avg merge
- 2d 9h
- Merged PRs (30d)
- 51
Description
### Describe the feature
I was using the brand new feature provided by this previous pull request.
- https://github.com/aws/aws-sdk-java-v2/issues/2292
Currently, the DynamoDbEnhancedClientExtension context object doesn't provide any additional context on an update/put operation besides the item being modified.
The lack of ability to pass in external variables into a client extension makes certain use cases of UpdateExpressions impossible without resorting to workarounds. This is doable in the non-enhanced client as I'm able to create update expressions in-line.
### Use Case
My specific use case is to decrement an unmapped value from my DynamoDB object using the UpdateExpression. Because my value is not mapped to my table schema, I'm unable to have visibility to the field in the scope of my custom extension documentation.
### Proposed Solution
A few ideas:
- A dirty solution would be to allow for visibility of DynamoDB attributes marked as @DynamoDbIgnore to be visible in the DynamoDbExtensionContext.items map. Currently, the itemsMap passed into the context only contains DDB-mapped attributes.
- A better solution would be to allow access to the attribute names/value maps defined at the time of performing the put/update operation in the context (extension runtime).
- Finally, a third solution would be to allow for inline update expressions at the time of creating an update on an item. This would need to be added to the regular update request, batch update request, and transact update request. This might work well with the proposed idea of having one-time update expressions as explained in the blog post here https://aws.amazon.com/blogs/developer/using-atomic-counters-in-the-enhanced-dynamodb-aws-sdk-for-java-2-x-client/
### Other Information
As a workaround, I've added a mapped attribute to the database that I am using solely for the purpose of gaining visibility into the extension. While this works fine, it is added a constantly updated and otherwise, redundant, attribute to my schema.
### Acknowledgements
- [ ] I may be able to implement this feature request
- [ ] This feature might incur a breaking change
### AWS Java SDK version used
2.17.196
### JDK version used
corretto-1.8.0_332
### Operating System and version
macOS. Monterey 12.4
Contributor guide
Assessment
This issue has not been assessed yet.