aws-sdk-java-v2 icon indicating copy to clipboard operation
aws-sdk-java-v2 copied to clipboard

Dynamodb enhanced flattened prefixing 

Open akiesler opened this issue 1 year ago • 2 comments

This pull request adds the ability for flattened beans to have a prefix attached to their flattened attributes. This enables clients to avoid conflicts in field names with flattening Beans with the same attribute name. This change supports 3 modes of setting the prefix.

  1. Explicitly setting the prefix on the annotation.
  2. Determine the prefix from the existing attribute name.
  3. Determine the prefix from the @DynamoDbAttribute annotation.

Motivation and Context

We regularly use an Edit Bean containing an actor and timestamp to track both creation and updates. When flattening the fields we experience a conflict as both beans share the same attributes.

Reference: https://github.com/aws/aws-sdk-java-v2/issues/3695

Modifications

Modified Static Table Schema to enable setting the prefixes programmatically. Modified Bean Schema builders to determine prefixes from @DynamoDbFlatten annotations.

Testing

Implemented Unit Tests to ensure that prefixing logic worked as expected.

Screenshots (if appropriate)

Types of changes

  • [ ] Bug fix (non-breaking change which fixes an issue)
  • [X] New feature (non-breaking change which adds functionality)

Checklist

  • [X] I have read the CONTRIBUTING document
  • [ ] Local run of mvn install succeeds
  • [X] My code follows the code style of this project
  • [X] My change requires a change to the Javadoc documentation
  • [X] I have updated the Javadoc documentation accordingly
  • [X] I have added tests to cover my changes
  • [X] All new and existing tests passed
  • [ ] I have added a changelog entry. Adding a new entry must be accomplished by running the scripts/new-change script and following the instructions. Commit the new file created by the script in .changes/next-release with your changes.
  • [ ] My change is to implement 1.11 parity feature and I have updated LaunchChangelog

License

  • [x] I confirm that this pull request can be released under the Apache 2 license

akiesler avatar Sep 16 '24 19:09 akiesler

Build is failing because of the japicmp target. Would appreciate insights on how to address this issue.

Failed to execute goal com.github.siom79.japicmp:japicmp-maven-plugin:0.15.6:cmp (default) on project dynamodb-enhanced: There is at least one incompatibility: software.amazon.awssdk.enhanced.dynamodb.mapper.annotations.DynamoDbFlatten.prefix():METHOD_ABSTRACT_ADDED_TO_CLASS 

akiesler avatar Sep 16 '24 19:09 akiesler

@debora-ito could you please review this feature? It seems like there is still significant interest in this feature.

akiesler avatar Feb 04 '25 21:02 akiesler