You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I encountered unexpected behavior regarding the last_evaluated_key attribute of the ResultIterator returned by Model.sacn() when implementing manual pagination.
It seems that the last_evaluated_key attribute is correctly populated with the value from the Dynamodb response only after the iterator has been consumed(eg by calling list) or iterating through it in a for loop
Accessing results.last_evaluated_key immediately after the scan() call returns, but before consuming the results iterator, consistently yielded None in my tests, even when the underlying DynamoDB response should have contained a non-null LastEvaluatedKey (indicating more pages are available). This prevents manual pagination logic that checks the key before processing the items.
# Not started iterating yet: return `exclusive_start_key` if set, otherwise expect None; or,
# Entire page has been consumed: last_evaluated_key is whatever DynamoDB returned
# It may correspond to the current item, or it may correspond to an item evaluated but not returned.
returnself.page_iter.last_evaluated_key
This could've been better documented, but I also think it's hard to believe someone should rely on scan not making the API call until you start iterating, so perhaps we can change this behavior.
@ikonst
Thanks for the quick response and clarification! I understand the reasoning behind the lazy loading now, based on the comment you linked.
I agree with your assessment that it's "hard to believe someone should rely on scan not making the API call until you start iterating".
Uh oh!
There was an error while loading. Please reload this page.
Envrionment
6.0.2
1.34.138
1.34.144
3.9
Description
last_evaluated_key
attribute of theResultIterator
returned byModel.sacn()
when implementing manual pagination.last_evaluated_key
attribute is correctly populated with the value from the Dynamodb response only after the iterator has been consumed(eg by callinglist
) or iterating through it in a for loopExample
The text was updated successfully, but these errors were encountered: