Skip to content

Commit 6148e5b

Browse files
Google APIscopybara-github
authored andcommitted
feat: publish proto definitions for SUM/AVG in Datastore
PiperOrigin-RevId: 552847139
1 parent 7154a94 commit 6148e5b

3 files changed

Lines changed: 63 additions & 13 deletions

File tree

google/datastore/v1/datastore.proto

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -578,9 +578,12 @@ message ReadOptions {
578578
// [RunQueryResponse.transaction][google.datastore.v1.RunQueryResponse.transaction].
579579
TransactionOptions new_transaction = 3;
580580

581-
// Reads entities as they were at the given time. This may not be older
582-
// than 270 seconds. This value is only supported for Cloud Firestore in
583-
// Datastore mode.
581+
// Reads entities as they were at the given time. This value is only
582+
// supported for Cloud Firestore in Datastore mode.
583+
//
584+
// This must be a microsecond precision timestamp within the past one hour,
585+
// or if Point-in-Time Recovery is enabled, can additionally be a whole
586+
// minute timestamp within the past 7 days.
584587
google.protobuf.Timestamp read_time = 4;
585588
}
586589
}
@@ -602,7 +605,10 @@ message TransactionOptions {
602605
// Options specific to read-only transactions.
603606
message ReadOnly {
604607
// Reads entities at the given time.
605-
// This may not be older than 60 seconds.
608+
//
609+
// This must be a microsecond precision timestamp within the past one hour,
610+
// or if Point-in-Time Recovery is enabled, can additionally be a whole
611+
// minute timestamp within the past 7 days.
606612
google.protobuf.Timestamp read_time = 1;
607613
}
608614

google/datastore/v1/datastore_v1.yaml

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,6 @@ documentation:
1111
summary: |-
1212
Accesses the schemaless NoSQL database to provide fully managed, robust,
1313
scalable storage for your application.
14-
rules:
15-
- selector: google.longrunning.Operations.ListOperations
16-
description: |-
17-
Lists operations that match the specified filter in the request. If
18-
the server doesn't support this method, it returns `UNIMPLEMENTED`.
1914
2015
backend:
2116
rules:

google/datastore/v1/query.proto

Lines changed: 53 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -163,10 +163,58 @@ message AggregationQuery {
163163
[(google.api.field_behavior) = OPTIONAL];
164164
}
165165

166+
// Sum of the values of the requested property.
167+
//
168+
// * Only numeric values will be aggregated. All non-numeric values
169+
// including `NULL` are skipped.
170+
//
171+
// * If the aggregated values contain `NaN`, returns `NaN`. Infinity math
172+
// follows IEEE-754 standards.
173+
//
174+
// * If the aggregated value set is empty, returns 0.
175+
//
176+
// * Returns a 64-bit integer if all aggregated numbers are integers and the
177+
// sum result does not overflow. Otherwise, the result is returned as a
178+
// double. Note that even if all the aggregated values are integers, the
179+
// result is returned as a double if it cannot fit within a 64-bit signed
180+
// integer. When this occurs, the returned value will lose precision.
181+
//
182+
// * When underflow occurs, floating-point aggregation is non-deterministic.
183+
// This means that running the same query repeatedly without any changes to
184+
// the underlying values could produce slightly different results each
185+
// time. In those cases, values should be stored as integers over
186+
// floating-point numbers.
187+
message Sum {
188+
// The property to aggregate on.
189+
PropertyReference property = 1;
190+
}
191+
192+
// Average of the values of the requested property.
193+
//
194+
// * Only numeric values will be aggregated. All non-numeric values
195+
// including `NULL` are skipped.
196+
//
197+
// * If the aggregated values contain `NaN`, returns `NaN`. Infinity math
198+
// follows IEEE-754 standards.
199+
//
200+
// * If the aggregated value set is empty, returns `NULL`.
201+
//
202+
// * Always returns the result as a double.
203+
message Avg {
204+
// The property to aggregate on.
205+
PropertyReference property = 1;
206+
}
207+
166208
// The type of aggregation to perform, required.
167209
oneof operator {
168210
// Count aggregator.
169211
Count count = 1;
212+
213+
// Sum aggregator.
214+
Sum sum = 2;
215+
216+
// Average aggregator.
217+
Avg avg = 3;
170218
}
171219

172220
// Optional. Optional name of the property to store the result of the
@@ -342,8 +390,9 @@ message PropertyFilter {
342390
//
343391
// Requires:
344392
//
345-
// * That `value` is a non-empty `ArrayValue` with at most 10 values.
346-
// * No other `IN` or `NOT_IN` is in the same query.
393+
// * That `value` is a non-empty `ArrayValue`, subject to disjunction
394+
// limits.
395+
// * No `NOT_IN` is in the same query.
347396
IN = 6;
348397

349398
// The given `property` is not equal to the given `value`.
@@ -359,15 +408,15 @@ message PropertyFilter {
359408
// Requires:
360409
//
361410
// * That `value` is an entity key.
362-
// * No other `HAS_ANCESTOR` is in the same query.
411+
// * All evaluated disjunctions must have the same `HAS_ANCESTOR` filter.
363412
HAS_ANCESTOR = 11;
364413

365414
// The value of the `property` is not in the given array.
366415
//
367416
// Requires:
368417
//
369418
// * That `value` is a non-empty `ArrayValue` with at most 10 values.
370-
// * No other `IN`, `NOT_IN`, `NOT_EQUAL` is in the same query.
419+
// * No other `OR`, `IN`, `NOT_IN`, `NOT_EQUAL` is in the same query.
371420
// * That `field` comes first in the `order_by`.
372421
NOT_IN = 13;
373422
}

0 commit comments

Comments
 (0)