-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Closed
boto/botocore
#3203Labels
bugThis issue is a confirmed bug.This issue is a confirmed bug.dynamodbp2This is a standard priority issueThis is a standard priority issuepagination
Description
Describe the bug
Pagination for dynamodb fails when the partition key is of type number.
This happens because the returned LastEvaluatedKey is of type Decimal and it cannot be json encoded (json.dumps fails). This happens in botocore.paginate.encode it tries to do convert the token to string.
This issue talks about the issue with Decimal types. The gist is that a Number type is returned like this { value: 3} -> { value: { N: Decimal("3")}}. This cannot be converted to string by json.
Steps to reproduce
- Create a table, choose Number as type of partition key, choose a sort key (anything is fine)
- Add two records with same partition key and different sort key
- Run a query similar to the following.
ddb_client = boto3.resource("dynamodb").meta.client
query_paginator = ddb_client.get_paginator("query")
page_iterator = query_paginator.paginate(
TableName=<TABLE-NAME>,
KeyConditionExpression=Key(<PK>).eq(<PK-VALUE>),
ScanIndexForward=False,
PaginationConfig = {
MaxItems: 1,
PageSize: 1,
}
)
for page in page_iterator:
for return_value in page["Items"]:
print(return_value)
Expected behavior
Pagination should succeed. It should handle the Decimal type by itself.
antoinejeannot
Metadata
Metadata
Assignees
Labels
bugThis issue is a confirmed bug.This issue is a confirmed bug.dynamodbp2This is a standard priority issueThis is a standard priority issuepagination