Skip to content

Commit

Permalink
feat: Support the Count aggregation query (#368)
Browse files Browse the repository at this point in the history
* feat: Support the Count aggregation query
* Add `run_aggregation_query` interface to the http client.

Co-authored-by: Owl Bot <gcf-owl-bot[bot]@users.noreply.github.com>
Co-authored-by: Anthonios Partheniou <partheniou@google.com>
  • Loading branch information
3 people committed Nov 1, 2022
1 parent a3cf688 commit b400a9a
Show file tree
Hide file tree
Showing 9 changed files with 1,310 additions and 0 deletions.
6 changes: 6 additions & 0 deletions docs/aggregations.rst
@@ -0,0 +1,6 @@
Aggregations
~~~~~~~~~~~~

.. automodule:: google.cloud.datastore.aggregation
:members:
:show-inheritance:
1 change: 1 addition & 0 deletions docs/index.rst
Expand Up @@ -18,6 +18,7 @@ API Reference
entities
keys
queries
aggregations
transactions
batches
helpers
Expand Down
33 changes: 33 additions & 0 deletions google/cloud/datastore/_http.py
Expand Up @@ -280,6 +280,39 @@ def run_query(self, request, retry=None, timeout=None):
timeout=timeout,
)

def run_aggregation_query(self, request, retry=None, timeout=None):
"""Perform a ``runAggregationQuery`` request.
:type request: :class:`_datastore_pb2.BeginTransactionRequest` or dict
:param request:
Parameter bundle for API request.
:type retry: :class:`google.api_core.retry.Retry`
:param retry: (Optional) retry policy for the request
:type timeout: float or tuple(float, float)
:param timeout: (Optional) timeout for the request
:rtype: :class:`.datastore_pb2.RunAggregationQueryResponse`
:returns: The returned protobuf response object.
"""
request_pb = _make_request_pb(
request, _datastore_pb2.RunAggregationQueryRequest
)
project_id = request_pb.project_id

return _rpc(
self.client._http,
project_id,
"runAggregationQuery",
self.client._base_url,
self.client._client_info,
request_pb,
_datastore_pb2.RunAggregationQueryResponse,
retry=retry,
timeout=timeout,
)

def begin_transaction(self, request, retry=None, timeout=None):
"""Perform a ``beginTransaction`` request.
Expand Down

0 comments on commit b400a9a

Please sign in to comment.