Cloud Datastore V1 Client - Class Aggregation (1.24.4)

Reference documentation and code samples for the Cloud Datastore V1 Client class Aggregation.

Defines an aggregation that produces a single result.

Generated from protobuf messagegoogle.datastore.v1.AggregationQuery.Aggregation

Namespace

Google \ Cloud \ Datastore \ V1 \ AggregationQuery

Methods

__construct

Constructor.

Parameters
NameDescription
dataarray

Optional. Data for populating the Message object.

↳ countGoogle\Cloud\Datastore\V1\AggregationQuery\Aggregation\Count

Count aggregator.

↳ sumGoogle\Cloud\Datastore\V1\AggregationQuery\Aggregation\Sum

Sum aggregator.

↳ avgGoogle\Cloud\Datastore\V1\AggregationQuery\Aggregation\Avg

Average aggregator.

↳ aliasstring

Optional. Optional name of the property to store the result of the aggregation. If not provided, Datastore will pick a default name following the formatproperty_<incremental_id++>. For example:AGGREGATE COUNT_UP_TO(1) AS count_up_to_1, COUNT_UP_TO(2), COUNT_UP_TO(3) AS count_up_to_3, COUNT(*) OVER ( ... ); becomes:AGGREGATE COUNT_UP_TO(1) AS count_up_to_1, COUNT_UP_TO(2) AS property_1, COUNT_UP_TO(3) AS count_up_to_3, COUNT(*) AS property_2 OVER ( ... ); Requires: * Must be unique across all aggregation aliases. * Conform toentity property name limitations.

getCount

Count aggregator.

Returns
TypeDescription
Google\Cloud\Datastore\V1\AggregationQuery\Aggregation\Count|null

hasCount

setCount

Count aggregator.

Parameter
NameDescription
varGoogle\Cloud\Datastore\V1\AggregationQuery\Aggregation\Count
Returns
TypeDescription
$this

getSum

Sum aggregator.

Returns
TypeDescription
Google\Cloud\Datastore\V1\AggregationQuery\Aggregation\Sum|null

hasSum

setSum

Sum aggregator.

Parameter
NameDescription
varGoogle\Cloud\Datastore\V1\AggregationQuery\Aggregation\Sum
Returns
TypeDescription
$this

getAvg

Average aggregator.

Returns
TypeDescription
Google\Cloud\Datastore\V1\AggregationQuery\Aggregation\Avg|null

hasAvg

setAvg

Average aggregator.

Parameter
NameDescription
varGoogle\Cloud\Datastore\V1\AggregationQuery\Aggregation\Avg
Returns
TypeDescription
$this

getAlias

Returns
TypeDescription
string

setAlias

Optional. Optional name of the property to store the result of theaggregation.

If not provided, Datastore will pick a default name following the formatproperty_<incremental_id++>. For example:

AGGREGATE  COUNT_UP_TO(1) AS count_up_to_1,  COUNT_UP_TO(2),  COUNT_UP_TO(3) AS count_up_to_3,  COUNT(*)OVER (  ...);

becomes:

AGGREGATE  COUNT_UP_TO(1) AS count_up_to_1,  COUNT_UP_TO(2) AS property_1,  COUNT_UP_TO(3) AS count_up_to_3,  COUNT(*) AS property_2OVER (  ...);

Requires:

Parameter
NameDescription
varstring
Returns
TypeDescription
$this

getOperator

Returns
TypeDescription
string

Except as otherwise noted, the content of this page is licensed under theCreative Commons Attribution 4.0 License, and code samples are licensed under theApache 2.0 License. For details, see theGoogle Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.

Last updated 2026-01-24 UTC.