Class: Google::Cloud::Datastore::V1::AggregationQuery

Inherits:
Object
  • Object
show all
Extended by:
Protobuf::MessageExts::ClassMethods
Includes:
Protobuf::MessageExts
Defined in:
proto_docs/google/datastore/v1/query.rb

Overview

Datastore query for running an aggregation over a Query.

Defined Under Namespace

Classes: Aggregation

Instance Attribute Summary collapse

Instance Attribute Details

#aggregations::Array<::Google::Cloud::Datastore::V1::AggregationQuery::Aggregation>

Returns Optional. Series of aggregations to apply over the results of the nested_query.

Requires:

  • A minimum of one and maximum of five aggregations per query.

Returns:



143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
# File 'proto_docs/google/datastore/v1/query.rb', line 143

class AggregationQuery
  include ::Google::Protobuf::MessageExts
  extend ::Google::Protobuf::MessageExts::ClassMethods

  # Defines an aggregation that produces a single result.
  # @!attribute [rw] count
  #   @return [::Google::Cloud::Datastore::V1::AggregationQuery::Aggregation::Count]
  #     Count aggregator.
  # @!attribute [rw] sum
  #   @return [::Google::Cloud::Datastore::V1::AggregationQuery::Aggregation::Sum]
  #     Sum aggregator.
  # @!attribute [rw] avg
  #   @return [::Google::Cloud::Datastore::V1::AggregationQuery::Aggregation::Avg]
  #     Average aggregator.
  # @!attribute [rw] alias
  #   @return [::String]
  #     Optional. Optional name of the property to store the result of the
  #     aggregation.
  #
  #     If not provided, Datastore will pick a default name following the format
  #     `property_<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 to [entity property
  #     name][google.datastore.v1.Entity.properties] limitations.
  class Aggregation
    include ::Google::Protobuf::MessageExts
    extend ::Google::Protobuf::MessageExts::ClassMethods

    # Count of entities that match the query.
    #
    # The `COUNT(*)` aggregation function operates on the entire entity
    # so it does not require a field reference.
    # @!attribute [rw] up_to
    #   @return [::Google::Protobuf::Int64Value]
    #     Optional. Optional constraint on the maximum number of entities to
    #     count.
    #
    #     This provides a way to set an upper bound on the number of entities
    #     to scan, limiting latency, and cost.
    #
    #     Unspecified is interpreted as no bound.
    #
    #     If a zero value is provided, a count result of zero should always be
    #     expected.
    #
    #     High-Level Example:
    #
    #     ```
    #     AGGREGATE COUNT_UP_TO(1000) OVER ( SELECT * FROM k );
    #     ```
    #
    #     Requires:
    #
    #     * Must be non-negative when present.
    class Count
      include ::Google::Protobuf::MessageExts
      extend ::Google::Protobuf::MessageExts::ClassMethods
    end

    # Sum of the values of the requested property.
    #
    # * Only numeric values will be aggregated. All non-numeric values
    # including `NULL` are skipped.
    #
    # * If the aggregated values contain `NaN`, returns `NaN`. Infinity math
    # follows IEEE-754 standards.
    #
    # * If the aggregated value set is empty, returns 0.
    #
    # * Returns a 64-bit integer if all aggregated numbers are integers and the
    # sum result does not overflow. Otherwise, the result is returned as a
    # double. Note that even if all the aggregated values are integers, the
    # result is returned as a double if it cannot fit within a 64-bit signed
    # integer. When this occurs, the returned value will lose precision.
    #
    # * When underflow occurs, floating-point aggregation is non-deterministic.
    # This means that running the same query repeatedly without any changes to
    # the underlying values could produce slightly different results each
    # time. In those cases, values should be stored as integers over
    # floating-point numbers.
    # @!attribute [rw] property
    #   @return [::Google::Cloud::Datastore::V1::PropertyReference]
    #     The property to aggregate on.
    class Sum
      include ::Google::Protobuf::MessageExts
      extend ::Google::Protobuf::MessageExts::ClassMethods
    end

    # Average of the values of the requested property.
    #
    # * Only numeric values will be aggregated. All non-numeric values
    # including `NULL` are skipped.
    #
    # * If the aggregated values contain `NaN`, returns `NaN`. Infinity math
    # follows IEEE-754 standards.
    #
    # * If the aggregated value set is empty, returns `NULL`.
    #
    # * Always returns the result as a double.
    # @!attribute [rw] property
    #   @return [::Google::Cloud::Datastore::V1::PropertyReference]
    #     The property to aggregate on.
    class Avg
      include ::Google::Protobuf::MessageExts
      extend ::Google::Protobuf::MessageExts::ClassMethods
    end
  end
end

#nested_query::Google::Cloud::Datastore::V1::Query

Returns Nested query for aggregation.

Returns:



143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
# File 'proto_docs/google/datastore/v1/query.rb', line 143

class AggregationQuery
  include ::Google::Protobuf::MessageExts
  extend ::Google::Protobuf::MessageExts::ClassMethods

  # Defines an aggregation that produces a single result.
  # @!attribute [rw] count
  #   @return [::Google::Cloud::Datastore::V1::AggregationQuery::Aggregation::Count]
  #     Count aggregator.
  # @!attribute [rw] sum
  #   @return [::Google::Cloud::Datastore::V1::AggregationQuery::Aggregation::Sum]
  #     Sum aggregator.
  # @!attribute [rw] avg
  #   @return [::Google::Cloud::Datastore::V1::AggregationQuery::Aggregation::Avg]
  #     Average aggregator.
  # @!attribute [rw] alias
  #   @return [::String]
  #     Optional. Optional name of the property to store the result of the
  #     aggregation.
  #
  #     If not provided, Datastore will pick a default name following the format
  #     `property_<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 to [entity property
  #     name][google.datastore.v1.Entity.properties] limitations.
  class Aggregation
    include ::Google::Protobuf::MessageExts
    extend ::Google::Protobuf::MessageExts::ClassMethods

    # Count of entities that match the query.
    #
    # The `COUNT(*)` aggregation function operates on the entire entity
    # so it does not require a field reference.
    # @!attribute [rw] up_to
    #   @return [::Google::Protobuf::Int64Value]
    #     Optional. Optional constraint on the maximum number of entities to
    #     count.
    #
    #     This provides a way to set an upper bound on the number of entities
    #     to scan, limiting latency, and cost.
    #
    #     Unspecified is interpreted as no bound.
    #
    #     If a zero value is provided, a count result of zero should always be
    #     expected.
    #
    #     High-Level Example:
    #
    #     ```
    #     AGGREGATE COUNT_UP_TO(1000) OVER ( SELECT * FROM k );
    #     ```
    #
    #     Requires:
    #
    #     * Must be non-negative when present.
    class Count
      include ::Google::Protobuf::MessageExts
      extend ::Google::Protobuf::MessageExts::ClassMethods
    end

    # Sum of the values of the requested property.
    #
    # * Only numeric values will be aggregated. All non-numeric values
    # including `NULL` are skipped.
    #
    # * If the aggregated values contain `NaN`, returns `NaN`. Infinity math
    # follows IEEE-754 standards.
    #
    # * If the aggregated value set is empty, returns 0.
    #
    # * Returns a 64-bit integer if all aggregated numbers are integers and the
    # sum result does not overflow. Otherwise, the result is returned as a
    # double. Note that even if all the aggregated values are integers, the
    # result is returned as a double if it cannot fit within a 64-bit signed
    # integer. When this occurs, the returned value will lose precision.
    #
    # * When underflow occurs, floating-point aggregation is non-deterministic.
    # This means that running the same query repeatedly without any changes to
    # the underlying values could produce slightly different results each
    # time. In those cases, values should be stored as integers over
    # floating-point numbers.
    # @!attribute [rw] property
    #   @return [::Google::Cloud::Datastore::V1::PropertyReference]
    #     The property to aggregate on.
    class Sum
      include ::Google::Protobuf::MessageExts
      extend ::Google::Protobuf::MessageExts::ClassMethods
    end

    # Average of the values of the requested property.
    #
    # * Only numeric values will be aggregated. All non-numeric values
    # including `NULL` are skipped.
    #
    # * If the aggregated values contain `NaN`, returns `NaN`. Infinity math
    # follows IEEE-754 standards.
    #
    # * If the aggregated value set is empty, returns `NULL`.
    #
    # * Always returns the result as a double.
    # @!attribute [rw] property
    #   @return [::Google::Cloud::Datastore::V1::PropertyReference]
    #     The property to aggregate on.
    class Avg
      include ::Google::Protobuf::MessageExts
      extend ::Google::Protobuf::MessageExts::ClassMethods
    end
  end
end