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
Count limits #86
Count limits #86
Conversation
The mypy failure is at |
Will be done in #87 |
b3c1fbf
to
9abcda0
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code-wise LGTM from me.
@ojii if the new functionality is reasonable.
I've merged #87, if you rebase the tests should be all green ❇️ :) |
9abcda0
to
acf87c0
Compare
tests/integration/test_client.py
Outdated
hk = HashKey("h", "k") | ||
assert await client.count(table, hk, limit=1) == 0 | ||
await client.put_item(table, {"h": "k", "r": "0"}) | ||
for i in range(1, 20): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what's the reason for repeating this 20 times?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wanted to call it more than a few times to ensure the limit parameter was being correctly applied. The number 20 is arbitrary.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like that idea, but I think the loop adds little value. Instead, how about testing these scenarios:
- 1 item table, limit 1 (tests a full count despite limit)
- 2 item table, limit 1 (tests a single page partial count)
- table above page size, limit larger than page size but not all items (tests a multi page partial count)
There's lots of other potential scenarios, but I feel like these are the most important. The main point I'm trying to suggest is to test specific scenarios, rather than the same one 20 times.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sounds good, but what is the page size? I know from experience on our production DynamoDB instances some tables would return around 10k items using a single query. I think it depends on the sizes of the items?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hm I see
aiodynamo/tests/integration/test_client.py
Line 259 in 29c7ae7
async def test_query_with_limit(client: Client, high_throughput_table: TableName): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ojii Test reworked!
Would a |
Yes, had this been available I would have used it. On a high level though, what I really want is to count with a limit so that's what I implemented. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe I'll slop limit onto the docs after merge :clever:
@@ -745,6 +747,7 @@ async def count( | |||
start_key: Optional[Dict[str, Any]] = None, | |||
filter_expression: Optional[Condition] = None, | |||
index: Optional[str] = None, | |||
limit: Optional[int] = None, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Documentation needs to be updated :)
This was motivated by our real-life use case. We sometimes need to limit counting to preserve latency and Dynamo resources. I tried using
query_single_page
but it doesn't support count queries, so I just addedlimit
tocount
.