Skip to content

Commit facfc5a

Browse files
Google APIscopybara-github
authored andcommitted
feat: add PartitionQuery and BatchWrite RPCs
feat: add update_transforms field to Write proto feat: add IS_NOT_NAN and IS_NOT_NULL filters on fields fix: retry RESOURCE_EXHAUSTED errors docs: various documentation improvements PiperOrigin-RevId: 367039635
1 parent 7007925 commit facfc5a

7 files changed

Lines changed: 273 additions & 63 deletions

File tree

google/firestore/v1beta1/common.proto

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright 2019 Google LLC.
1+
// Copyright 2021 Google LLC
22
//
33
// Licensed under the Apache License, Version 2.0 (the "License");
44
// you may not use this file except in compliance with the License.
@@ -11,7 +11,6 @@
1111
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1212
// See the License for the specific language governing permissions and
1313
// limitations under the License.
14-
//
1514

1615
syntax = "proto3";
1716

google/firestore/v1beta1/document.proto

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright 2019 Google LLC.
1+
// Copyright 2021 Google LLC
22
//
33
// Licensed under the Apache License, Version 2.0 (the "License");
44
// you may not use this file except in compliance with the License.
@@ -11,7 +11,6 @@
1111
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1212
// See the License for the specific language governing permissions and
1313
// limitations under the License.
14-
//
1514

1615
syntax = "proto3";
1716

google/firestore/v1beta1/firestore.proto

Lines changed: 164 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright 2019 Google LLC.
1+
// Copyright 2021 Google LLC
22
//
33
// Licensed under the Apache License, Version 2.0 (the "License");
44
// you may not use this file except in compliance with the License.
@@ -11,7 +11,6 @@
1111
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1212
// See the License for the specific language governing permissions and
1313
// limitations under the License.
14-
//
1514

1615
syntax = "proto3";
1716

@@ -41,20 +40,12 @@ option ruby_package = "Google::Cloud::Firestore::V1beta1";
4140

4241
// The Cloud Firestore service.
4342
//
44-
// This service exposes several types of comparable timestamps:
45-
//
46-
// * `create_time` - The time at which a document was created. Changes only
47-
// when a document is deleted, then re-created. Increases in a strict
48-
// monotonic fashion.
49-
// * `update_time` - The time at which a document was last updated. Changes
50-
// every time a document is modified. Does not change when a write results
51-
// in no modifications. Increases in a strict monotonic fashion.
52-
// * `read_time` - The time at which a particular state was observed. Used
53-
// to denote a consistent snapshot of the database or the time at which a
54-
// Document was observed to not exist.
55-
// * `commit_time` - The time at which the writes in a transaction were
56-
// committed. Any read with an equal or greater `read_time` is guaranteed
57-
// to see the effects of the transaction.
43+
// Cloud Firestore is a fast, fully managed, serverless, cloud-native NoSQL
44+
// document database that simplifies storing, syncing, and querying data for
45+
// your mobile, web, and IoT apps at global scale. Its client libraries provide
46+
// live synchronization and offline support, while its security features and
47+
// integrations with Firebase and Google Cloud Platform (GCP) accelerate
48+
// building truly serverless apps.
5849
service Firestore {
5950
option (google.api.default_host) = "firestore.googleapis.com";
6051
option (google.api.oauth_scopes) =
@@ -75,14 +66,6 @@ service Firestore {
7566
};
7667
}
7768

78-
// Creates a new document.
79-
rpc CreateDocument(CreateDocumentRequest) returns (Document) {
80-
option (google.api.http) = {
81-
post: "/v1beta1/{parent=projects/*/databases/*/documents/**}/{collection_id}"
82-
body: "document"
83-
};
84-
}
85-
8669
// Updates or inserts a document.
8770
rpc UpdateDocument(UpdateDocumentRequest) returns (Document) {
8871
option (google.api.http) = {
@@ -150,6 +133,20 @@ service Firestore {
150133
};
151134
}
152135

136+
// Partitions a query by returning partition cursors that can be used to run
137+
// the query in parallel. The returned partition cursors are split points that
138+
// can be used by RunQuery as starting/end points for the query results.
139+
rpc PartitionQuery(PartitionQueryRequest) returns (PartitionQueryResponse) {
140+
option (google.api.http) = {
141+
post: "/v1beta1/{parent=projects/*/databases/*/documents}:partitionQuery"
142+
body: "*"
143+
additional_bindings {
144+
post: "/v1beta1/{parent=projects/*/databases/*/documents/*/**}:partitionQuery"
145+
body: "*"
146+
}
147+
};
148+
}
149+
153150
// Streams batches of document updates and deletes, in order.
154151
rpc Write(stream WriteRequest) returns (stream WriteResponse) {
155152
option (google.api.http) = {
@@ -178,6 +175,30 @@ service Firestore {
178175
};
179176
option (google.api.method_signature) = "parent";
180177
}
178+
179+
// Applies a batch of write operations.
180+
//
181+
// The BatchWrite method does not apply the write operations atomically
182+
// and can apply them out of order. Method does not allow more than one write
183+
// per document. Each write succeeds or fails independently. See the
184+
// [BatchWriteResponse][google.firestore.v1beta1.BatchWriteResponse] for the success status of each write.
185+
//
186+
// If you require an atomically applied set of writes, use
187+
// [Commit][google.firestore.v1beta1.Firestore.Commit] instead.
188+
rpc BatchWrite(BatchWriteRequest) returns (BatchWriteResponse) {
189+
option (google.api.http) = {
190+
post: "/v1beta1/{database=projects/*/databases/*}/documents:batchWrite"
191+
body: "*"
192+
};
193+
}
194+
195+
// Creates a new document.
196+
rpc CreateDocument(CreateDocumentRequest) returns (Document) {
197+
option (google.api.http) = {
198+
post: "/v1beta1/{parent=projects/*/databases/*/documents/**}/{collection_id}"
199+
body: "document"
200+
};
201+
}
181202
}
182203

183204
// The request for [Firestore.GetDocument][google.firestore.v1beta1.Firestore.GetDocument].
@@ -199,7 +220,7 @@ message GetDocumentRequest {
199220
bytes transaction = 3;
200221

201222
// Reads the version of the document at the given time.
202-
// This may not be older than 60 seconds.
223+
// This may not be older than 270 seconds.
203224
google.protobuf.Timestamp read_time = 5;
204225
}
205226
}
@@ -240,7 +261,7 @@ message ListDocumentsRequest {
240261
bytes transaction = 8;
241262

242263
// Reads documents as they were at the given time.
243-
// This may not be older than 60 seconds.
264+
// This may not be older than 270 seconds.
244265
google.protobuf.Timestamp read_time = 10;
245266
}
246267

@@ -356,7 +377,7 @@ message BatchGetDocumentsRequest {
356377
TransactionOptions new_transaction = 5;
357378

358379
// Reads documents as they were at the given time.
359-
// This may not be older than 60 seconds.
380+
// This may not be older than 270 seconds.
360381
google.protobuf.Timestamp read_time = 7;
361382
}
362383
}
@@ -426,7 +447,8 @@ message CommitResponse {
426447
// request.
427448
repeated WriteResult write_results = 1;
428449

429-
// The time at which the commit occurred.
450+
// The time at which the commit occurred. Any read with an equal or greater
451+
// `read_time` is guaranteed to see the effects of the commit.
430452
google.protobuf.Timestamp commit_time = 2;
431453
}
432454

@@ -469,7 +491,7 @@ message RunQueryRequest {
469491
TransactionOptions new_transaction = 6;
470492

471493
// Reads documents as they were at the given time.
472-
// This may not be older than 60 seconds.
494+
// This may not be older than 270 seconds.
473495
google.protobuf.Timestamp read_time = 7;
474496
}
475497
}
@@ -500,6 +522,85 @@ message RunQueryResponse {
500522
int32 skipped_results = 4;
501523
}
502524

525+
// The request for [Firestore.PartitionQuery][google.firestore.v1beta1.Firestore.PartitionQuery].
526+
message PartitionQueryRequest {
527+
// Required. The parent resource name. In the format:
528+
// `projects/{project_id}/databases/{database_id}/documents`.
529+
// Document resource names are not supported; only database resource names
530+
// can be specified.
531+
string parent = 1 [(google.api.field_behavior) = REQUIRED];
532+
533+
// The query to partition.
534+
oneof query_type {
535+
// A structured query.
536+
// Query must specify collection with all descendants and be ordered by name
537+
// ascending. Other filters, order bys, limits, offsets, and start/end
538+
// cursors are not supported.
539+
StructuredQuery structured_query = 2;
540+
}
541+
542+
// The desired maximum number of partition points.
543+
// The partitions may be returned across multiple pages of results.
544+
// The number must be positive. The actual number of partitions
545+
// returned may be fewer.
546+
//
547+
// For example, this may be set to one fewer than the number of parallel
548+
// queries to be run, or in running a data pipeline job, one fewer than the
549+
// number of workers or compute instances available.
550+
int64 partition_count = 3;
551+
552+
// The `next_page_token` value returned from a previous call to
553+
// PartitionQuery that may be used to get an additional set of results.
554+
// There are no ordering guarantees between sets of results. Thus, using
555+
// multiple sets of results will require merging the different result sets.
556+
//
557+
// For example, two subsequent calls using a page_token may return:
558+
//
559+
// * cursor B, cursor M, cursor Q
560+
// * cursor A, cursor U, cursor W
561+
//
562+
// To obtain a complete result set ordered with respect to the results of the
563+
// query supplied to PartitionQuery, the results sets should be merged:
564+
// cursor A, cursor B, cursor M, cursor Q, cursor U, cursor W
565+
string page_token = 4;
566+
567+
// The maximum number of partitions to return in this call, subject to
568+
// `partition_count`.
569+
//
570+
// For example, if `partition_count` = 10 and `page_size` = 8, the first call
571+
// to PartitionQuery will return up to 8 partitions and a `next_page_token`
572+
// if more results exist. A second call to PartitionQuery will return up to
573+
// 2 partitions, to complete the total of 10 specified in `partition_count`.
574+
int32 page_size = 5;
575+
}
576+
577+
// The response for [Firestore.PartitionQuery][google.firestore.v1beta1.Firestore.PartitionQuery].
578+
message PartitionQueryResponse {
579+
// Partition results.
580+
// Each partition is a split point that can be used by RunQuery as a starting
581+
// or end point for the query results. The RunQuery requests must be made with
582+
// the same query supplied to this PartitionQuery request. The partition
583+
// cursors will be ordered according to same ordering as the results of the
584+
// query supplied to PartitionQuery.
585+
//
586+
// For example, if a PartitionQuery request returns partition cursors A and B,
587+
// running the following three queries will return the entire result set of
588+
// the original query:
589+
//
590+
// * query, end_at A
591+
// * query, start_at A, end_at B
592+
// * query, start_at B
593+
//
594+
// An empty result may indicate that the query has too few results to be
595+
// partitioned.
596+
repeated Cursor partitions = 1;
597+
598+
// A page token that may be used to request an additional set of results, up
599+
// to the number specified by `partition_count` in the PartitionQuery request.
600+
// If blank, there are no more results.
601+
string next_page_token = 2;
602+
}
603+
503604
// The request for [Firestore.Write][google.firestore.v1beta1.Firestore.Write].
504605
//
505606
// The first request creates a stream, or resumes an existing one from a token.
@@ -567,7 +668,8 @@ message WriteResponse {
567668
// request.
568669
repeated WriteResult write_results = 3;
569670

570-
// The time at which the commit occurred.
671+
// The time at which the commit occurred. Any read with an equal or greater
672+
// `read_time` is guaranteed to see the effects of the write.
571673
google.protobuf.Timestamp commit_time = 4;
572674
}
573675

@@ -764,3 +866,35 @@ message ListCollectionIdsResponse {
764866
// A page token that may be used to continue the list.
765867
string next_page_token = 2;
766868
}
869+
870+
// The request for [Firestore.BatchWrite][google.firestore.v1beta1.Firestore.BatchWrite].
871+
message BatchWriteRequest {
872+
// Required. The database name. In the format:
873+
// `projects/{project_id}/databases/{database_id}`.
874+
string database = 1 [(google.api.field_behavior) = REQUIRED];
875+
876+
// The writes to apply.
877+
//
878+
// Method does not apply writes atomically and does not guarantee ordering.
879+
// Each write succeeds or fails independently. You cannot write to the same
880+
// document more than once per request.
881+
repeated Write writes = 2;
882+
883+
// Labels associated with this batch write.
884+
map<string, string> labels = 3;
885+
}
886+
887+
// The response from [Firestore.BatchWrite][google.firestore.v1beta1.Firestore.BatchWrite].
888+
message BatchWriteResponse {
889+
// The result of applying the writes.
890+
//
891+
// This i-th write result corresponds to the i-th write in the
892+
// request.
893+
repeated WriteResult write_results = 1;
894+
895+
// The status of applying the writes.
896+
//
897+
// This i-th write status corresponds to the i-th write in the
898+
// request.
899+
repeated google.rpc.Status status = 2;
900+
}

google/firestore/v1beta1/firestore_grpc_service_config.json

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@
3434
"maxBackoff": "60s",
3535
"backoffMultiplier": 1.3,
3636
"retryableStatusCodes": [
37-
"RESOURCE_EXHAUSTED",
3837
"UNAVAILABLE",
3938
"DEADLINE_EXCEEDED"
4039
]
@@ -75,7 +74,6 @@
7574
"maxBackoff": "60s",
7675
"backoffMultiplier": 1.3,
7776
"retryableStatusCodes": [
78-
"RESOURCE_EXHAUSTED",
7977
"UNAVAILABLE",
8078
"DEADLINE_EXCEEDED"
8179
]
@@ -95,7 +93,6 @@
9593
"maxBackoff": "60s",
9694
"backoffMultiplier": 1.3,
9795
"retryableStatusCodes": [
98-
"RESOURCE_EXHAUSTED",
9996
"UNAVAILABLE",
10097
"DEADLINE_EXCEEDED"
10198
]

google/firestore/v1beta1/firestore_v1beta1.yaml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,16 +10,36 @@ documentation:
1010
summary: |-
1111
Accesses the NoSQL document database built for automatic scaling, high
1212
performance, and ease of application development.
13+
rules:
14+
- selector: google.cloud.location.Locations.GetLocation
15+
description: Gets information about a location.
16+
17+
- selector: google.cloud.location.Locations.ListLocations
18+
description: Lists information about the supported locations for this service.
1319

1420
backend:
1521
rules:
22+
- selector: google.cloud.location.Locations.GetLocation
23+
deadline: 295.0
24+
- selector: google.cloud.location.Locations.ListLocations
25+
deadline: 295.0
1626
- selector: 'google.firestore.v1beta1.Firestore.*'
1727
deadline: 295.0
1828
- selector: 'google.longrunning.Operations.*'
1929
deadline: 295.0
2030

2131
authentication:
2232
rules:
33+
- selector: google.cloud.location.Locations.GetLocation
34+
oauth:
35+
canonical_scopes: |-
36+
https://www.googleapis.com/auth/cloud-platform,
37+
https://www.googleapis.com/auth/datastore
38+
- selector: google.cloud.location.Locations.ListLocations
39+
oauth:
40+
canonical_scopes: |-
41+
https://www.googleapis.com/auth/cloud-platform,
42+
https://www.googleapis.com/auth/datastore
2343
- selector: 'google.firestore.v1beta1.Firestore.*'
2444
oauth:
2545
canonical_scopes: |-

0 commit comments

Comments
 (0)