-
Notifications
You must be signed in to change notification settings - Fork 75
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
feat: Sum/Avg aggregation queries #715
Conversation
Adds the ability to perform sum/avg aggregation query through: - query.sum(), - query.avg(), - async_query.sum(), - async_query.avg()
tests/system/test_system.py
Outdated
for aggregation_result in result: | ||
assert aggregation_result.alias in ["total", "all"] | ||
|
||
|
||
@firestore.transactional |
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.
can we add some additional tests for transactions using sum/avg?
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 added a couple, let me know what you think
@@ -507,6 +507,30 @@ def count(self, alias=None): | |||
""" | |||
return self._aggregation_query().count(alias=alias) | |||
|
|||
def sum(self, field_ref: str, alias=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.
does FieldPath need to be appended here as well?
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.
good catch! Fixed
(The type checking system should have caught this, but it looks like it's not running properly. I'll have to fix that in a separate PR)
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.
sgtm, please file an issue for tracking!
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 have a bug for it here: #773
Note: the new EDIT: we are going to release with tests skipped, and re-enable them when the backend fix is ready |
Adds the ability to perform sum/avg aggregation query through:
Thank you for opening a Pull Request! Before submitting your PR, there are a few things you can do to make sure it goes smoothly:
Fixes #<issue_number_goes_here> 🦕