Skip to content

Commit ccadec5

Browse files
feat: publish proto definitions for SUM/AVG in Firestore (#746)
* feat: publish proto definitions for SUM/AVG in Firestore PiperOrigin-RevId: 552607134 Source-Link: googleapis/googleapis@88a9a5f Source-Link: googleapis/googleapis-gen@047d73a Copy-Tag: eyJwIjoiLmdpdGh1Yi8uT3dsQm90LnlhbWwiLCJoIjoiMDQ3ZDczYWUyZmQ0ZTUyNmI0NzRhNjE3ZTE2ODMzOWQ2OTFiMjUxMCJ9 * 🦉 Updates from OwlBot post-processor See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md --------- Co-authored-by: Owl Bot <gcf-owl-bot[bot]@users.noreply.github.com> Co-authored-by: Anthonios Partheniou <partheniou@google.com>
1 parent 3f3c550 commit ccadec5

File tree

4 files changed

+130
-19
lines changed

4 files changed

+130
-19
lines changed

google/cloud/firestore_v1/types/common.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,8 @@ class TransactionOptions(proto.Message):
116116
class ReadWrite(proto.Message):
117117
r"""Options for a transaction that can be used to read and write
118118
documents.
119+
Firestore does not allow 3rd party auth requests to create
120+
read-write. transactions.
119121
120122
Attributes:
121123
retry_transaction (bytes):
@@ -137,7 +139,10 @@ class ReadOnly(proto.Message):
137139
Attributes:
138140
read_time (google.protobuf.timestamp_pb2.Timestamp):
139141
Reads documents at the given time.
140-
This may not be older than 60 seconds.
142+
This must be a microsecond precision timestamp
143+
within the past one hour, or if Point-in-Time
144+
Recovery is enabled, can additionally be a whole
145+
minute timestamp within the past 7 days.
141146
142147
This field is a member of `oneof`_ ``consistency_selector``.
143148
"""

google/cloud/firestore_v1/types/firestore.py

Lines changed: 33 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -93,8 +93,11 @@ class GetDocumentRequest(proto.Message):
9393
This field is a member of `oneof`_ ``consistency_selector``.
9494
read_time (google.protobuf.timestamp_pb2.Timestamp):
9595
Reads the version of the document at the
96-
given time. This may not be older than 270
97-
seconds.
96+
given time.
97+
This must be a microsecond precision timestamp
98+
within the past one hour, or if Point-in-Time
99+
Recovery is enabled, can additionally be a whole
100+
minute timestamp within the past 7 days.
98101
99102
This field is a member of `oneof`_ ``consistency_selector``.
100103
"""
@@ -186,7 +189,10 @@ class ListDocumentsRequest(proto.Message):
186189
This field is a member of `oneof`_ ``consistency_selector``.
187190
read_time (google.protobuf.timestamp_pb2.Timestamp):
188191
Perform the read at the provided time.
189-
This may not be older than 270 seconds.
192+
This must be a microsecond precision timestamp
193+
within the past one hour, or if Point-in-Time
194+
Recovery is enabled, can additionally be a whole
195+
minute timestamp within the past 7 days.
190196
191197
This field is a member of `oneof`_ ``consistency_selector``.
192198
show_missing (bool):
@@ -447,7 +453,11 @@ class BatchGetDocumentsRequest(proto.Message):
447453
This field is a member of `oneof`_ ``consistency_selector``.
448454
read_time (google.protobuf.timestamp_pb2.Timestamp):
449455
Reads documents as they were at the given
450-
time. This may not be older than 270 seconds.
456+
time.
457+
This must be a microsecond precision timestamp
458+
within the past one hour, or if Point-in-Time
459+
Recovery is enabled, can additionally be a whole
460+
minute timestamp within the past 7 days.
451461
452462
This field is a member of `oneof`_ ``consistency_selector``.
453463
"""
@@ -699,7 +709,11 @@ class RunQueryRequest(proto.Message):
699709
This field is a member of `oneof`_ ``consistency_selector``.
700710
read_time (google.protobuf.timestamp_pb2.Timestamp):
701711
Reads documents as they were at the given
702-
time. This may not be older than 270 seconds.
712+
time.
713+
This must be a microsecond precision timestamp
714+
within the past one hour, or if Point-in-Time
715+
Recovery is enabled, can additionally be a whole
716+
minute timestamp within the past 7 days.
703717
704718
This field is a member of `oneof`_ ``consistency_selector``.
705719
"""
@@ -836,10 +850,10 @@ class RunAggregationQueryRequest(proto.Message):
836850
This field is a member of `oneof`_ ``consistency_selector``.
837851
read_time (google.protobuf.timestamp_pb2.Timestamp):
838852
Executes the query at the given timestamp.
839-
840-
Requires:
841-
842-
- Cannot be more than 270 seconds in the past.
853+
This must be a microsecond precision timestamp
854+
within the past one hour, or if Point-in-Time
855+
Recovery is enabled, can additionally be a whole
856+
minute timestamp within the past 7 days.
843857
844858
This field is a member of `oneof`_ ``consistency_selector``.
845859
"""
@@ -975,7 +989,11 @@ class PartitionQueryRequest(proto.Message):
975989
``partition_count``.
976990
read_time (google.protobuf.timestamp_pb2.Timestamp):
977991
Reads documents as they were at the given
978-
time. This may not be older than 270 seconds.
992+
time.
993+
This must be a microsecond precision timestamp
994+
within the past one hour, or if Point-in-Time
995+
Recovery is enabled, can additionally be a whole
996+
minute timestamp within the past 7 days.
979997
980998
This field is a member of `oneof`_ ``consistency_selector``.
981999
"""
@@ -1550,7 +1568,11 @@ class ListCollectionIdsRequest(proto.Message):
15501568
[ListCollectionIdsResponse][google.firestore.v1.ListCollectionIdsResponse].
15511569
read_time (google.protobuf.timestamp_pb2.Timestamp):
15521570
Reads documents as they were at the given
1553-
time. This may not be older than 270 seconds.
1571+
time.
1572+
This must be a microsecond precision timestamp
1573+
within the past one hour, or if Point-in-Time
1574+
Recovery is enabled, can additionally be a whole
1575+
minute timestamp within the past 7 days.
15541576
15551577
This field is a member of `oneof`_ ``consistency_selector``.
15561578
"""

google/cloud/firestore_v1/types/query.py

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -568,12 +568,25 @@ class StructuredAggregationQuery(proto.Message):
568568
class Aggregation(proto.Message):
569569
r"""Defines an aggregation that produces a single result.
570570
571+
This message has `oneof`_ fields (mutually exclusive fields).
572+
For each oneof, at most one member field can be set at the same time.
573+
Setting any member of the oneof automatically clears all other
574+
members.
575+
571576
.. _oneof: https://proto-plus-python.readthedocs.io/en/stable/fields.html#oneofs-mutually-exclusive-fields
572577
573578
Attributes:
574579
count (google.cloud.firestore_v1.types.StructuredAggregationQuery.Aggregation.Count):
575580
Count aggregator.
576581
582+
This field is a member of `oneof`_ ``operator``.
583+
sum (google.cloud.firestore_v1.types.StructuredAggregationQuery.Aggregation.Sum):
584+
Sum aggregator.
585+
586+
This field is a member of `oneof`_ ``operator``.
587+
avg (google.cloud.firestore_v1.types.StructuredAggregationQuery.Aggregation.Avg):
588+
Average aggregator.
589+
577590
This field is a member of `oneof`_ ``operator``.
578591
alias (str):
579592
Optional. Optional name of the field to store the result of
@@ -647,12 +660,83 @@ class Count(proto.Message):
647660
message=wrappers_pb2.Int64Value,
648661
)
649662

663+
class Sum(proto.Message):
664+
r"""Sum of the values of the requested field.
665+
666+
- Only numeric values will be aggregated. All non-numeric values
667+
including ``NULL`` are skipped.
668+
669+
- If the aggregated values contain ``NaN``, returns ``NaN``.
670+
Infinity math follows IEEE-754 standards.
671+
672+
- If the aggregated value set is empty, returns 0.
673+
674+
- Returns a 64-bit integer if all aggregated numbers are integers
675+
and the sum result does not overflow. Otherwise, the result is
676+
returned as a double. Note that even if all the aggregated values
677+
are integers, the result is returned as a double if it cannot fit
678+
within a 64-bit signed integer. When this occurs, the returned
679+
value will lose precision.
680+
681+
- When underflow occurs, floating-point aggregation is
682+
non-deterministic. This means that running the same query
683+
repeatedly without any changes to the underlying values could
684+
produce slightly different results each time. In those cases,
685+
values should be stored as integers over floating-point numbers.
686+
687+
Attributes:
688+
field (google.cloud.firestore_v1.types.StructuredQuery.FieldReference):
689+
The field to aggregate on.
690+
"""
691+
692+
field: "StructuredQuery.FieldReference" = proto.Field(
693+
proto.MESSAGE,
694+
number=1,
695+
message="StructuredQuery.FieldReference",
696+
)
697+
698+
class Avg(proto.Message):
699+
r"""Average of the values of the requested field.
700+
701+
- Only numeric values will be aggregated. All non-numeric values
702+
including ``NULL`` are skipped.
703+
704+
- If the aggregated values contain ``NaN``, returns ``NaN``.
705+
Infinity math follows IEEE-754 standards.
706+
707+
- If the aggregated value set is empty, returns ``NULL``.
708+
709+
- Always returns the result as a double.
710+
711+
Attributes:
712+
field (google.cloud.firestore_v1.types.StructuredQuery.FieldReference):
713+
The field to aggregate on.
714+
"""
715+
716+
field: "StructuredQuery.FieldReference" = proto.Field(
717+
proto.MESSAGE,
718+
number=1,
719+
message="StructuredQuery.FieldReference",
720+
)
721+
650722
count: "StructuredAggregationQuery.Aggregation.Count" = proto.Field(
651723
proto.MESSAGE,
652724
number=1,
653725
oneof="operator",
654726
message="StructuredAggregationQuery.Aggregation.Count",
655727
)
728+
sum: "StructuredAggregationQuery.Aggregation.Sum" = proto.Field(
729+
proto.MESSAGE,
730+
number=2,
731+
oneof="operator",
732+
message="StructuredAggregationQuery.Aggregation.Sum",
733+
)
734+
avg: "StructuredAggregationQuery.Aggregation.Avg" = proto.Field(
735+
proto.MESSAGE,
736+
number=3,
737+
oneof="operator",
738+
message="StructuredAggregationQuery.Aggregation.Avg",
739+
)
656740
alias: str = proto.Field(
657741
proto.STRING,
658742
number=7,

google/cloud/firestore_v1/types/write.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -474,16 +474,16 @@ class ExistenceFilter(proto.Message):
474474
longer match the target.
475475
476476
The client can use the ``unchanged_names`` bloom filter to
477-
assist with this determination.
477+
assist with this determination by testing ALL the document
478+
names against the filter; if the document name is NOT in the
479+
filter, it means the document no longer matches the target.
478480
unchanged_names (google.cloud.firestore_v1.types.BloomFilter):
479-
A bloom filter that contains the UTF-8 byte encodings of the
480-
resource names of the documents that match
481+
A bloom filter that, despite its name, contains the UTF-8
482+
byte encodings of the resource names of ALL the documents
483+
that match
481484
[target_id][google.firestore.v1.ExistenceFilter.target_id],
482485
in the form
483-
``projects/{project_id}/databases/{database_id}/documents/{document_path}``
484-
that have NOT changed since the query results indicated by
485-
the resume token or timestamp given in
486-
``Target.resume_type``.
486+
``projects/{project_id}/databases/{database_id}/documents/{document_path}``.
487487
488488
This bloom filter may be omitted at the server's discretion,
489489
such as if it is deemed that the client will not make use of

0 commit comments

Comments
 (0)