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

DynamoDB enhanced client - Add "Select" in QueryEnhancedRequest #2083

Closed
1 task
felixchin opened this issue Oct 12, 2020 · 16 comments
Closed
1 task

DynamoDB enhanced client - Add "Select" in QueryEnhancedRequest #2083

felixchin opened this issue Oct 12, 2020 · 16 comments
Labels
dynamodb-enhanced feature-request A feature should be added or improved. p2 This is a standard priority issue

Comments

@felixchin
Copy link

felixchin commented Oct 12, 2020

There is no "Select" in QueryEnhancedRequest Builder.

Describe the Feature

Query the Dynamodb and return only the count.

Is your Feature Request related to a problem?

No

Proposed Solution

QueryEnhancedRequest.builder().select(Select select)
The select should has those enums

  • ALL_ATTRIBUTES
  • ALL_PROJECTED_ATTRIBUTES
  • SPECIFIC_ATTRIBUTES
  • COUNT

Describe alternatives you've considered

Just use QueryRequest instead of QueryEnhancedRequest

Additional Context

  • I may be able to implement this feature request

Your Environment

  • AWS Java SDK version used: 2.14.13
  • JDK version used: 1.8
  • Operating System and version: macOs
@felixchin felixchin added feature-request A feature should be added or improved. needs-triage This issue or PR still needs to be triaged. labels Oct 12, 2020
@debora-ito debora-ito added dynamodb-enhanced and removed needs-triage This issue or PR still needs to be triaged. labels Oct 20, 2020
@debora-ito
Copy link
Member

@felixchin to confirm, this is mostly to obtain the COUNT number? Because you can specify the attributes to be retrieved from the database in the attributesToProject field.

@driverpt
Copy link

driverpt commented Mar 1, 2021

Any updates on this ?

@RushinNaik
Copy link

"return only the count" functionality would be useful.

@divyasshanmugam
Copy link

is this available ?

@shivavamsi
Copy link

Any update on this issue?

@mvershinin-chwy
Copy link

Is there a workaround for this?

@sanggenOh
Copy link

Have feature to implement?

@AkramMo
Copy link

AkramMo commented Feb 15, 2022

Any workaround found ?

@debora-ito
Copy link
Member

No updates here other than this is in our backlog.

As a reminder, please add a 👍 reaction in the original description of the issue to show interest, it helps us prioritizing all the feature requests we have.

aws-sdk-java-automation added a commit that referenced this issue Jul 6, 2022
…4e694ecbd

Pull request: release <- staging/a646a935-4c68-41d6-9394-be94e694ecbd
@yasminetalby yasminetalby added the p2 This is a standard priority issue label Nov 28, 2022
@dimitarz
Copy link

Sad it has been years and this issue has not been resolved yet.

There are two "workarounds":

  1. Implement counting with the classic DynamoDbClient, see example here.
  2. You can still use the Enhanced client by projecting a property that doesn't exist. This will return a null for each object. Then count the nulls in the returned list. Not super optimal but it works.
 var count = 0
 index.query(
 QueryEnhancedRequest.builder()
     .queryConditional(QueryConditional.keyEqualTo(key))
     .attributesToProject("COUNT")
     .build(),
 ).subscribe {
     count += it.items()?.size ?: 0
 }.await()

@debora-ito
Copy link
Member

Sorry for the late update:

"count" was released in SDK version 2.20.153 (via #4444).

Page now exposes count, scanned count and consumed capacity - https://sdk.amazonaws.com/java/api/latest/software/amazon/awssdk/enhanced/dynamodb/model/Page.html

Copy link

github-actions bot commented Apr 3, 2024

This issue is now closed. Comments on closed issues are hard for our team to see.
If you need more assistance, please open a new issue that references this one.

@millems
Copy link
Contributor

millems commented Apr 19, 2024

Reopening because while the SDK supports returning the count field, it doesn't support specifying the select parameter on the query request. This means that items still need to be retrieved from the service just to get the count.

The only workarounds available at this time are to use an execution interceptor that adds the setting to the request, or to use the low-level client to retrieve the count.

@millems millems reopened this Apr 19, 2024
@AndyBette
Copy link

The most efficient option is probably to use select via the low-level client to get the count. To minimize the amount of data transferred when using the enhanced client for count specifically, project none of the attributes of the item when scanning or querying.

The DynamoDB service team is tracking internally the feature request to add the rest of the select functionality to the enhanced client.

@debora-ito
Copy link
Member

"Select" is now supported in QueryEnhancedRequest (released in version 2.26.25) and ScanEnhancedRequest (released in version 2.27.19). This includes the "SELECT(COUNT)" option.

Copy link

This issue is now closed. Comments on closed issues are hard for our team to see.
If you need more assistance, please open a new issue that references this one.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
dynamodb-enhanced feature-request A feature should be added or improved. p2 This is a standard priority issue
Projects
None yet
Development

No branches or pull requests