DDB Enhanced: table created without indices
See original GitHub issueDescribe the Feature
DynamoDbTable.createTable()
creates the table without global and local indices and there is no way how to obtain the information from TableMetadata
Is your Feature Request related to a problem?
I’m trying to create the DynamoDB table based on DDE Enhanced mappings if it does not exist but the table is created without the indices and I’m not able to get the information without any hacks.
Proposed Solution
- minimal solution would be to expose the key set of
StaticTableMetadata.indexByNameMap
in theTableMetadata
interface, i.g.TableMetadata.indexNames
. - ideal solution is that
DynamoDbTable.createTable()
will prefill the request with the indices which has been read from the annotations.
Describe alternatives you’ve considered
I can use reflective access to indexByNameMap
but this would be very brittle.
Additional Context
I’m trying to implement DynamoDB declarative services for Micronaut library using v2
https://agorapulse.github.io/micronaut-aws-sdk/#_declarative_services_with_service
This missing feature breaks the parity with the previous version where IDynamoDBMapper.generateCreateTableRequest()
method returned the request populated with indices definitions.
- I may be able to implement this feature request
Your Environment
- AWS Java SDK version used: 2.11.10
- JDK version used: 1.8
- Operating System and version: Darwin
Issue Analytics
- State:
- Created 3 years ago
- Comments:19 (13 by maintainers)
@djake It definitely sucks that the sdk just ignores the indices defined in the schemas. From my understanding of the back and forth in this issue: in order to create indices, you need to know the projection and provisioned throughput, which isn’t available in the
TableSchema
. Arguably, this information doesn’t make sense to include in the schema for the rare scenario where you use it to create a table, so that’s why you need that uglyCreateTableEnhancedRequest
to enable it.Personally, I use the mappers to create tables all the time for my automated tests, so this missing feature is huge downer for me. I’ve been working on a plugin to make the v2 enhanced sdk palatable for kotlin data classes, and I made this helper method that seems to work well enough for my mock dynamo environment.
Improved @oharaandrew314 suggestion together with @denniseffing to also check if local/global secondary indices exists before creating: