Open esotuvaka opened 3 weeks ago
Thanks for the feedback! We are routing this to the appropriate team for follow-up. cc @AbhinavTrips @bambriz @pilchie @pjohari-ms @simorenoh.
Hello @esotuvaka Thank you for bringing this to our attention. I have not been able to reproduce the bug mentioned here. I ran the two scenarios you mentioned and got the expected behaviour when using max item count. How are you using the methods mentioned in your code? This is what I have:
paginated_queried_items = paginated_query_all_items(container, continuation_token=None)
continuation_token = list(paginated_queried_items)[1]
while continuation_token is not None:
paginated_queried_items = paginated_query_all_items(container, continuation_token=continuation_token)
continuation_token = list(paginated_queried_items)[1]
With the 7 items in the container I get 7 items back in one pagination when max_item_count is 10 and 7 through 4 paginations when it is 2.
Describe the bug I've adapted the code examples below directly from the python-azure-sdk samples section of the github repo: https://github.com/Azure/azure-sdk-for-python/blob/main/sdk/cosmos/azure-cosmos/samples/document_management.py#L88
Part 1: Specifying a max_item_count greater than the number of documents present in cosmos DB returns 0 documents, despite there being documents present in Cosmos DB. My current workaround has been to set the max_item_count to 1, which does enable pagination, but will not scale. Part 2: The other half to this bug is when we paginate, if the final page is less than max_item_count, the page will return back as empty.
Part 1: For example, having 7 documents in Cosmos DB with a max_item_count of 10 can not be paginated by the code below, because the first page is returned with 0 documents. Part 2: For example, having 7 documents in Cosmos DB with a max_item_count of 2 can be paginated by the code below, but the final page that should return 1 document actually returns [] no documents, I suspect also because of Part 1's bug where the max_item_count is now larger than the number of documents remaining.
Specifying no max_item_count will also trigger this bug.
To Reproduce Steps to reproduce the behavior: PART 1:
PART 2:
Expected behavior I expected that max_item_count would return up to the max_item_count number of documents. If the documentation could be adapted to show a working example that would be great, as in my research online I've found limited / incomplete resources for Cosmos DB Python SDK paginated requests. Thank you
Additional context N/A