Skip to content

Commit

Permalink
feat: add new types QueryMode, QueryPlan, ResultSetStats
Browse files Browse the repository at this point in the history
feat: add QueryMode field to RunQueryRequest
feat: add ResultSetStats field to RunQueryResponse
feat: add QueryMode field to RunAggregationQueryRequest
feat: add ResultSetStats field to RunAggregationQueryResponse

PiperOrigin-RevId: 595774772
  • Loading branch information
Google APIs authored and Copybara-Service committed Jan 4, 2024
1 parent 6585871 commit 03e7ed4
Show file tree
Hide file tree
Showing 3 changed files with 99 additions and 0 deletions.
1 change: 1 addition & 0 deletions google/datastore/v1/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ proto_library(
"datastore.proto",
"entity.proto",
"query.proto",
"query_profile.proto",
],
deps = [
"//google/api:annotations_proto",
Expand Down
23 changes: 23 additions & 0 deletions google/datastore/v1/datastore.proto
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import "google/api/routing.proto";
import "google/datastore/v1/aggregation_result.proto";
import "google/datastore/v1/entity.proto";
import "google/datastore/v1/query.proto";
import "google/datastore/v1/query_profile.proto";
import "google/protobuf/timestamp.proto";

option csharp_namespace = "Google.Cloud.Datastore.V1";
Expand Down Expand Up @@ -232,6 +233,11 @@ message RunQueryRequest {
// The GQL query to run. This query must be a non-aggregation query.
GqlQuery gql_query = 7;
}

// Optional. The mode in which the query request is processed. This field is
// optional, and when not provided, it defaults to `NORMAL` mode where no
// additional statistics will be returned with the query results.
QueryMode mode = 11 [(google.api.field_behavior) = OPTIONAL];
}

// The response for
Expand All @@ -251,6 +257,12 @@ message RunQueryResponse {
// was set in
// [RunQueryRequest.read_options][google.datastore.v1.RunQueryRequest.read_options].
bytes transaction = 5;

// Query plan and execution statistics. Note that the returned stats are
// subject to change as Firestore evolves.
//
// This is only present when the request specifies a mode other than `NORMAL`.
ResultSetStats stats = 6;
}

// The request for
Expand Down Expand Up @@ -282,6 +294,11 @@ message RunAggregationQueryRequest {
// The GQL query to run. This query must be an aggregation query.
GqlQuery gql_query = 7;
}

// Optional. The mode in which the query request is processed. This field is
// optional, and when not provided, it defaults to `NORMAL` mode where no
// additional statistics will be returned with the query results.
QueryMode mode = 10 [(google.api.field_behavior) = OPTIONAL];
}

// The response for
Expand All @@ -301,6 +318,12 @@ message RunAggregationQueryResponse {
// was set in
// [RunAggregationQueryRequest.read_options][google.datastore.v1.RunAggregationQueryRequest.read_options].
bytes transaction = 5;

// Query plan and execution statistics. Note that the returned stats are
// subject to change as Firestore evolves.
//
// This is only present when the request specifies a mode other than `NORMAL`.
ResultSetStats stats = 6;
}

// The request for
Expand Down
75 changes: 75 additions & 0 deletions google/datastore/v1/query_profile.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
// Copyright 2023 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

syntax = "proto3";

package google.datastore.v1;

import "google/protobuf/struct.proto";

option csharp_namespace = "Google.Cloud.Datastore.V1";
option go_package = "google.golang.org/genproto/googleapis/datastore/v1;datastore";
option java_multiple_files = true;
option java_outer_classname = "QueryProfileProto";
option java_package = "com.google.datastore.v1";
option php_namespace = "Google\\Cloud\\Datastore\\V1";
option ruby_package = "Google::Cloud::Datastore::V1";

// Specification of the Datastore Query Profile fields.

// The mode in which the query request must be processed.
enum QueryMode {
// The default mode. Only the query results are returned.
NORMAL = 0;

// This mode returns only the query plan, without any results or execution
// statistics information.
PLAN = 1;

// This mode returns both the query plan and the execution statistics along
// with the results.
PROFILE = 2;
}

// Plan for the query.
message QueryPlan {
// Planning phase information for the query. It will include:
//
// {
// "indexes_used": [
// {"query_scope": "Collection", "properties": "(foo ASC, __name__ ASC)"},
// {"query_scope": "Collection", "properties": "(bar ASC, __name__ ASC)"}
// ]
// }
google.protobuf.Struct plan_info = 1;
}

// Planning and execution statistics for the query.
message ResultSetStats {
// Plan for the query.
QueryPlan query_plan = 1;

// Aggregated statistics from the execution of the query.
//
// This will only be present when the request specifies `PROFILE` mode.
// For example, a query will return the statistics including:
//
// {
// "results_returned": "20",
// "documents_scanned": "20",
// "indexes_entries_scanned": "10050",
// "total_execution_time": "100.7 msecs"
// }
google.protobuf.Struct query_stats = 2;
}

0 comments on commit 03e7ed4

Please sign in to comment.