@@ -23,6 +23,7 @@ import "google/api/resource.proto";
2323import "google/api/routing.proto" ;
2424import "google/bigtable/v2/data.proto" ;
2525import "google/bigtable/v2/request_stats.proto" ;
26+ import "google/bigtable/v2/types.proto" ;
2627import "google/protobuf/duration.proto" ;
2728import "google/protobuf/timestamp.proto" ;
2829import "google/protobuf/wrappers.proto" ;
@@ -275,7 +276,24 @@ service Bigtable {
275276 option (google.api.method_signature ) = "table_name,app_profile_id" ;
276277 }
277278
278- // Executes a BTQL query against a particular Cloud Bigtable instance.
279+ // Prepares a GoogleSQL query for execution on a particular Bigtable instance.
280+ rpc PrepareQuery (PrepareQueryRequest ) returns (PrepareQueryResponse ) {
281+ option (google.api.http ) = {
282+ post : "/v2/{instance_name=projects/*/instances/*}:prepareQuery"
283+ body : "*"
284+ };
285+ option (google.api.routing ) = {
286+ routing_parameters {
287+ field : "instance_name"
288+ path_template : "{name=projects/*/instances/*}"
289+ }
290+ routing_parameters { field : "app_profile_id" }
291+ };
292+ option (google.api.method_signature ) = "instance_name,query" ;
293+ option (google.api.method_signature ) = "instance_name,query,app_profile_id" ;
294+ }
295+
296+ // Executes a SQL query against a particular Bigtable instance.
279297 rpc ExecuteQuery (ExecuteQueryRequest ) returns (stream ExecuteQueryResponse ) {
280298 option (google.api.http ) = {
281299 post : "/v2/{instance_name=projects/*/instances/*}:executeQuery"
@@ -1041,13 +1059,31 @@ message ExecuteQueryRequest {
10411059 string app_profile_id = 2 [(google.api.field_behavior ) = OPTIONAL ];
10421060
10431061 // Required. The query string.
1044- string query = 3 [(google.api.field_behavior ) = REQUIRED ];
1062+ //
1063+ // Exactly one of `query` and `prepared_query` is required. Setting both
1064+ // or neither is an `INVALID_ARGUMENT`.
1065+ string query = 3 [deprecated = true , (google.api.field_behavior ) = REQUIRED ];
10451066
1046- // Required. Requested data format for the response.
1067+ // A prepared query that was returned from `PrepareQueryResponse`.
1068+ //
1069+ // Exactly one of `query` and `prepared_query` is required. Setting both
1070+ // or neither is an `INVALID_ARGUMENT`.
1071+ //
1072+ // Setting this field also places restrictions on several other fields:
1073+ // - `data_format` must be empty.
1074+ // - `validate_only` must be false.
1075+ // - `params` must match the `param_types` set in the `PrepareQueryRequest`.
1076+ bytes prepared_query = 9 ;
1077+
1078+ // Requested data format for the response.
1079+ //
1080+ // If `prepared_query` is set, then the `data_format` is fixed by the
1081+ // `PrepareQueryRequest`, and a non-empty `data_format` in the
1082+ // `ExecuteQueryRequest` will be rejected with `INVALID_ARGUMENT`.
10471083 oneof data_format {
10481084 // Protocol buffer format as described by ProtoSchema and ProtoRows
10491085 // messages.
1050- ProtoFormat proto_format = 4 ;
1086+ ProtoFormat proto_format = 4 [ deprecated = true ] ;
10511087 }
10521088
10531089 // Optional. If this request is resuming a previously interrupted query
@@ -1067,17 +1103,21 @@ message ExecuteQueryRequest {
10671103 //
10681104 // For example, if
10691105 // `params["firstName"] = bytes_value: "foo" type {bytes_type {}}`
1070- // then `@firstName` will be replaced with googlesql bytes value "foo" in the
1071- // query string during query evaluation.
1106+ // then `@firstName` will be replaced with googlesql bytes value "foo" in the
1107+ // query string during query evaluation.
10721108 //
1073- // In case of Value.kind is not set, it will be set to corresponding null
1074- // value in googlesql.
1075- // `params["firstName"] = type {string_type {}}`
1076- // then `@firstName` will be replaced with googlesql null string.
1109+ // If ` Value.kind` is not set, the value is treated as a NULL value of the
1110+ // given type. For example, if
1111+ // `params["firstName"] = type {string_type {}}`
1112+ // then `@firstName` will be replaced with googlesql null string.
10771113 //
1078- // Value.type should always be set and no inference of type will be made from
1079- // Value.kind. If Value.type is not set, we will return INVALID_ARGUMENT
1080- // error.
1114+ // If `query` is set, any empty `Value.type` in the map will be rejected with
1115+ // `INVALID_ARGUMENT`.
1116+ //
1117+ // If `prepared_query` is set, any empty `Value.type` in the map will be
1118+ // inferred from the `param_types` in the `PrepareQueryRequest`. Any non-empty
1119+ // `Value.type` must match the corresponding `param_types` entry, or be
1120+ // rejected with `INVALID_ARGUMENT`.
10811121 map <string , Value > params = 7 [(google.api.field_behavior ) = REQUIRED ];
10821122}
10831123
@@ -1100,3 +1140,63 @@ message ExecuteQueryResponse {
11001140 PartialResultSet results = 2 ;
11011141 }
11021142}
1143+
1144+ // Request message for Bigtable.PrepareQuery
1145+ message PrepareQueryRequest {
1146+ // Required. The unique name of the instance against which the query should be
1147+ // executed.
1148+ // Values are of the form `projects/<project>/instances/<instance>`
1149+ string instance_name = 1 [
1150+ (google.api.field_behavior ) = REQUIRED ,
1151+ (google.api.resource_reference ) = {
1152+ type : "bigtableadmin.googleapis.com/Instance"
1153+ }
1154+ ];
1155+
1156+ // Optional. This value specifies routing for preparing the query. Note that
1157+ // this `app_profile_id` is only used for preparing the query. The actual
1158+ // query execution will use the app profile specified in the
1159+ // `ExecuteQueryRequest`. If not specified, the `default` application profile
1160+ // will be used.
1161+ string app_profile_id = 2 [(google.api.field_behavior ) = OPTIONAL ];
1162+
1163+ // Required. The query string.
1164+ string query = 3 [(google.api.field_behavior ) = REQUIRED ];
1165+
1166+ // Required. Requested data format for the response. Note that the selected
1167+ // data format is binding for all `ExecuteQuery` rpcs that use the prepared
1168+ // query.
1169+ oneof data_format {
1170+ // Protocol buffer format as described by ProtoSchema and ProtoRows
1171+ // messages.
1172+ ProtoFormat proto_format = 4 ;
1173+ }
1174+
1175+ // Required. `param_types` is a map of parameter identifier strings to their
1176+ // `Type`s.
1177+ //
1178+ // In query string, a parameter placeholder consists of the
1179+ // `@` character followed by the parameter name (for example, `@firstName`) in
1180+ // the query string.
1181+ //
1182+ // For example, if param_types["firstName"] = Bytes then @firstName will be a
1183+ // query parameter of type Bytes. The specific `Value` to be used for the
1184+ // query execution must be sent in `ExecuteQueryRequest` in the `params` map.
1185+ map <string , Type > param_types = 6 [(google.api.field_behavior ) = REQUIRED ];
1186+ }
1187+
1188+ // Response message for Bigtable.PrepareQueryResponse
1189+ message PrepareQueryResponse {
1190+ // Structure of rows in the response stream of `ExecuteQueryResponse` for the
1191+ // returned `prepared_query`.
1192+ ResultSetMetadata metadata = 1 ;
1193+
1194+ // A serialized prepared query. Clients should treat this as an opaque
1195+ // blob of bytes to send in `ExecuteQueryRequest`.
1196+ bytes prepared_query = 2 ;
1197+
1198+ // The time at which the prepared query token becomes invalid.
1199+ // A token may become invalid early due to changes in the data being read, but
1200+ // it provides a guideline to refresh query plans asynchronously.
1201+ google.protobuf.Timestamp valid_until = 3 ;
1202+ }
0 commit comments