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

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

Overview

Defines an aggregation that produces a single result.

Defined Under Namespace

Classes: Avg, Count, Sum

Instance Attribute Summary collapse

Instance Attribute Details

#alias::String

Returns 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.

Returns:

  • (::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.


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
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
# File 'proto_docs/google/datastore/v1/query.rb', line 210

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

#avg::Google::Cloud::Datastore::V1::AggregationQuery::Aggregation::Avg

Returns Average aggregator.



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
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
# File 'proto_docs/google/datastore/v1/query.rb', line 210

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

#count::Google::Cloud::Datastore::V1::AggregationQuery::Aggregation::Count

Returns Count aggregator.



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
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
# File 'proto_docs/google/datastore/v1/query.rb', line 210

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

#sum::Google::Cloud::Datastore::V1::AggregationQuery::Aggregation::Sum

Returns Sum aggregator.



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
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
# File 'proto_docs/google/datastore/v1/query.rb', line 210

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