-
Notifications
You must be signed in to change notification settings - Fork 662
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
service/dynamodb scan() not providing consistent pagination limits #2957
Comments
Hi @ren123t, thanks for reaching out. I see that you are using a custom code for pagination. Would there be a reason why you are not using a built SDK pagination (https://docs.aws.amazon.com/code-library/latest/ug/go_2_dynamodb_code_examples.html) ?
Please let me know if you have any questions. Thanks. |
I originally wrote it when pagination wasn't needed, but now there's more granular filtering requirements added to it now. I didn't realize there was already a built in paginator in the sdk. i've done a quick update and it seems like the same behavior is still present. scan function:
function call:
this is in a test data set of about 13 items, Thanks! |
Hi @ren123t, thanks for the response. I have replicated your code on my side and yes DynamoDB scans and counts the unfiltered one within a page but does not output it. So even unfiltered items are counted and therefore one page would not be able to hold the filtered data and some will have to be moved to the next page. This is expected result as per the Dynamo DB service : https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/Scan.html#Scan.FilterExpression
Please let me know if you have any other questions. Thanks. |
Acknowledgements
go get -u github.com/aws/aws-sdk-go-v2/...
)Describe the bug
currently having an issue with the service/dynamodb code. it seems like the scan feature when provided a filter clause paginates first and returns output values after. not sure if this is intended but it interferes when trying to define pagination for requests that expect a consistent number of entries related to a requested page.
an example is a request like url.com/resource?page=3&limit=10&status=fail, if I provide a scan limit of 10 and status fail it will still count the non fail status entries in the limit to be paginated, so as I index each page I can get page results of: page:1 size 3, page:2 size 7, page:3 size:10, page:4 size:1... etc.
Regression Issue
Expected Behavior
When using scaninput.limit = any number (10) and a filter condition (X = Y) the dynamodb.scan() function would return pages of 10 filtered entries per limit each scan using lastevaluatedkey as the start index for the scanoutput
Current Behavior
dynamodb.scan() currently returns any next 10 entries from dynamodb and then filters, returning a variable x amount of entries in scanoutput
Reproduction Steps
scan wraper function being used:
Possible Solution
if there is a way to either filter before using limit or if there can be a middle function/secondary field that defines non-dynamodb pagination if dynamodb allows it.
Additional Information/Context
No response
AWS Go SDK V2 Module Versions Used
github.com/aws/aws-sdk-go-v2 v1.32.8
github.com/aws/aws-sdk-go-v2/feature/dynamodb/attributevalue v1.15.26
github.com/aws/aws-sdk-go-v2/feature/dynamodb/expression v1.7.61
github.com/aws/aws-sdk-go-v2/service/dynamodb v1.39.3
Compiler and Version used
go version go1.23.4 windows/amd64
Operating System and version
windows 10
The text was updated successfully, but these errors were encountered: