Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DynamoDBMapper.generateCreateTableRequest() - Forcing ProjectionType.KEYS_ONLY for all LSI #214

Closed
adaofeliz opened this issue Apr 11, 2014 · 6 comments
Labels
feature-request A feature should be added or improved.

Comments

@adaofeliz
Copy link

Hi,

it seems that it's not possible by using the DynamoDBMapper to create a table with a LSI that protects all the Attributes.

This feature is importante for iteration of the table using the DynamoDBMapper.query().

Why can't this be configurable in the DynamoDBIndexRangeKey Annotation?

I'm more than happy do the change and create a merge request, if you agree to accept it.

Thanks,

Adao

@hanshuo-aws
Copy link
Contributor

Hi Adao,

Not allowing index projection configuration is one of the limitations of the generateCreateTableRequest() method that we explicitly called out in our documentation.

The reason that we didn't make the Projection type configuration in the @DynamoDBIndexRangeKey annotation is because we want to avoid index definition in an attribute-level annotation. If we do allow that, then we would need more complicated code to deal with the possible scenario when different attributes reference to the same index but with conflict definition. Also, since @DynamoDBIndexRangeKey is shared by both LSI and GSI, we cannot make the assumption that they will always share the same configuration parameters.

It seems that the better way to go is to support index definition in a table-level annotation (e.g. @DynamoDBTable). This will give us more flexibility, and meanwhile keep the attribute-level annotations simple (they only serve as references to the indexes defined somewhere).

We will keep thinking about how to carry this out, but right now we don't have an ETA on that. I think currently you can create a simple helper function that processes the generated request and reset the Projection type to the one you want.

-Shuo

@adaofeliz
Copy link
Author

Hi Shuo,

in understand your points and it's true that this can cause a conflict if different attributes using the same index have different configurations, we can maybe have default fallback in this case.

Still in imho I expect something simply like this:

@DynamoDBIndexRangeKey(
attributeName = "timeRangeKey",
localSecondaryIndexName = "timeRangeKeyIndex"
protection = "ALL")

Where we can still have KEYS_ONLY as default.

My implementation was a simple overwrite:

CreateTableRequest createTableRequest = dynamoDBMapper.generateCreateTableRequest(...);
if (createTableRequest.getLocalSecondaryIndexes() != null) {
for (LocalSecondaryIndex localSecondaryIndex : createTableRequest.getLocalSecondaryIndexes()) {
// This will force that all attributes are returned during the Query of LSI
// on this particular case, we use DynamoDB as as queue so when we
// query dynamodb we always want everything to be returned.
localSecondaryIndex.setProjection(new Projection().withProjectionType(ProjectionType.ALL));
}
}

Thanks for your feedback, keep up with the good work!

@PauloMigAlmeida
Copy link
Contributor

I know I might be a little late for the party but I must express how sad it's to not have it implemented by now =/

@david-at-aws david-at-aws added the feature-request A feature should be added or improved. label Jul 27, 2015
@jbuddha
Copy link

jbuddha commented Mar 8, 2017

This will be a good feature.

@dbubenheim
Copy link

Is there any chance that this feature will be implemented soon, either on table or attribute level? Thanks in advance!

@debora-ito
Copy link
Member

debora-ito commented Apr 25, 2019

@adaofeliz @PauloMigAlmeida @jbuddha @dbubenheim

the SDK team has reviewed the feature request list for V1, and since they're concentrating efforts on V2 new features they decided to not implement this one in V1. It's still being considered for the DynamoDB Mapper refactor in V2, see the referenced issue above. I'll go ahead and close this one.

Please feel free to comment on the V2 issue with your use case, and reach out if you have further questions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature-request A feature should be added or improved.
Projects
None yet
Development

No branches or pull requests

7 participants