Skip to content

Commit

Permalink
feat: add database dialect
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 423930262
  • Loading branch information
Google APIs authored and Copybara-Service committed Jan 24, 2022
1 parent c09a336 commit b0c104f
Show file tree
Hide file tree
Showing 11 changed files with 131 additions and 87 deletions.
5 changes: 4 additions & 1 deletion google/spanner/admin/database/v1/backup.proto
Expand Up @@ -16,13 +16,13 @@ syntax = "proto3";

package google.spanner.admin.database.v1;

import "google/api/annotations.proto";
import "google/api/field_behavior.proto";
import "google/api/resource.proto";
import "google/longrunning/operations.proto";
import "google/protobuf/field_mask.proto";
import "google/protobuf/timestamp.proto";
import "google/spanner/admin/database/v1/common.proto";
import "google/api/annotations.proto";

option csharp_namespace = "Google.Cloud.Spanner.Admin.Database.V1";
option go_package = "google.golang.org/genproto/googleapis/spanner/admin/database/v1;database";
Expand Down Expand Up @@ -117,6 +117,9 @@ message Backup {

// Output only. The encryption information for the backup.
EncryptionInfo encryption_info = 8 [(google.api.field_behavior) = OUTPUT_ONLY];

// Output only. The database dialect information for the backup.
DatabaseDialect database_dialect = 10 [(google.api.field_behavior) = OUTPUT_ONLY];
}

// The request for [CreateBackup][google.spanner.admin.database.v1.DatabaseAdmin.CreateBackup].
Expand Down
15 changes: 14 additions & 1 deletion google/spanner/admin/database/v1/common.proto
Expand Up @@ -16,11 +16,11 @@ syntax = "proto3";

package google.spanner.admin.database.v1;

import "google/api/annotations.proto";
import "google/api/field_behavior.proto";
import "google/api/resource.proto";
import "google/protobuf/timestamp.proto";
import "google/rpc/status.proto";
import "google/api/annotations.proto";

option csharp_namespace = "Google.Cloud.Spanner.Admin.Database.V1";
option go_package = "google.golang.org/genproto/googleapis/spanner/admin/database/v1;database";
Expand Down Expand Up @@ -98,3 +98,16 @@ message EncryptionInfo {
}
];
}

// Indicates the dialect type of a database.
enum DatabaseDialect {
// Default value. This value will create a database with the
// GOOGLE_STANDARD_SQL dialect.
DATABASE_DIALECT_UNSPECIFIED = 0;

// Google standard SQL.
GOOGLE_STANDARD_SQL = 1;

// PostgreSQL supported SQL.
POSTGRESQL = 2;
}
18 changes: 14 additions & 4 deletions google/spanner/admin/database/v1/spanner_database_admin.proto
Expand Up @@ -24,6 +24,7 @@ import "google/iam/v1/iam_policy.proto";
import "google/iam/v1/policy.proto";
import "google/longrunning/operations.proto";
import "google/protobuf/empty.proto";
import "google/protobuf/field_mask.proto";
import "google/protobuf/timestamp.proto";
import "google/spanner/admin/database/v1/backup.proto";
import "google/spanner/admin/database/v1/common.proto";
Expand All @@ -42,10 +43,11 @@ option (google.api.resource_definition) = {

// Cloud Spanner Database Admin API
//
// The Cloud Spanner Database Admin API can be used to create, drop, and
// list databases. It also enables updating the schema of pre-existing
// databases. It can be also used to create, delete and list backups for a
// database and to restore from an existing backup.
// The Cloud Spanner Database Admin API can be used to:
// * create, drop, and list databases
// * update the schema of pre-existing databases
// * create, delete and list backups for a database
// * restore a database from an existing backup
service DatabaseAdmin {
option (google.api.default_host) = "spanner.googleapis.com";
option (google.api.oauth_scopes) =
Expand Down Expand Up @@ -110,6 +112,8 @@ service DatabaseAdmin {
// Drops (aka deletes) a Cloud Spanner database.
// Completed backups for the database will be retained according to their
// `expire_time`.
// Note: Cloud Spanner might continue to accept requests for a few seconds
// after the database has been deleted.
rpc DropDatabase(DropDatabaseRequest) returns (google.protobuf.Empty) {
option (google.api.http) = {
delete: "/v1/{database=projects/*/instances/*/databases/*}"
Expand Down Expand Up @@ -407,6 +411,9 @@ message Database {
// database option set using DatabaseAdmin.CreateDatabase or
// DatabaseAdmin.UpdateDatabaseDdl. If not explicitly set, this is empty.
string default_leader = 9 [(google.api.field_behavior) = OUTPUT_ONLY];

// Output only. The dialect of the Cloud Spanner Database.
DatabaseDialect database_dialect = 10 [(google.api.field_behavior) = OUTPUT_ONLY];
}

// The request for [ListDatabases][google.spanner.admin.database.v1.DatabaseAdmin.ListDatabases].
Expand Down Expand Up @@ -469,6 +476,9 @@ message CreateDatabaseRequest {
// specified, Cloud Spanner will encrypt/decrypt all data at rest using
// Google default encryption.
EncryptionConfig encryption_config = 4 [(google.api.field_behavior) = OPTIONAL];

// Optional. The dialect of the Cloud Spanner Database.
DatabaseDialect database_dialect = 5 [(google.api.field_behavior) = OPTIONAL];
}

// Metadata type for the operation returned by
Expand Down
6 changes: 3 additions & 3 deletions google/spanner/v1/commit_response.proto
Expand Up @@ -16,9 +16,9 @@ syntax = "proto3";

package google.spanner.v1;

import "google/api/annotations.proto";
import "google/protobuf/duration.proto";
import "google/protobuf/timestamp.proto";
import "google/api/annotations.proto";

option csharp_namespace = "Google.Cloud.Spanner.V1";
option go_package = "google.golang.org/genproto/googleapis/spanner/v1;spanner";
Expand All @@ -36,9 +36,9 @@ message CommitResponse {
// `mutation_count` value can help you maximize the number of mutations
// in a transaction and minimize the number of API round trips. You can
// also monitor this value to prevent transactions from exceeding the system
// [limit](http://cloud.google.com/spanner/quotas#limits_for_creating_reading_updating_and_deleting_data).
// [limit](https://cloud.google.com/spanner/quotas#limits_for_creating_reading_updating_and_deleting_data).
// If the number of mutations exceeds the limit, the server returns
// [INVALID_ARGUMENT](http://cloud.google.com/spanner/docs/reference/rest/v1/Code#ENUM_VALUES.INVALID_ARGUMENT).
// [INVALID_ARGUMENT](https://cloud.google.com/spanner/docs/reference/rest/v1/Code#ENUM_VALUES.INVALID_ARGUMENT).
int64 mutation_count = 1;
}

Expand Down
2 changes: 1 addition & 1 deletion google/spanner/v1/keys.proto
Expand Up @@ -16,8 +16,8 @@ syntax = "proto3";

package google.spanner.v1;

import "google/protobuf/struct.proto";
import "google/api/annotations.proto";
import "google/protobuf/struct.proto";

option csharp_namespace = "Google.Cloud.Spanner.V1";
option go_package = "google.golang.org/genproto/googleapis/spanner/v1;spanner";
Expand Down
4 changes: 2 additions & 2 deletions google/spanner/v1/mutation.proto
@@ -1,4 +1,4 @@
// Copyright 2020 Google LLC
// Copyright 2021 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand All @@ -16,9 +16,9 @@ syntax = "proto3";

package google.spanner.v1;

import "google/api/annotations.proto";
import "google/protobuf/struct.proto";
import "google/spanner/v1/keys.proto";
import "google/api/annotations.proto";

option csharp_namespace = "Google.Cloud.Spanner.V1";
option go_package = "google.golang.org/genproto/googleapis/spanner/v1;spanner";
Expand Down
38 changes: 19 additions & 19 deletions google/spanner/v1/query_plan.proto
Expand Up @@ -16,8 +16,8 @@ syntax = "proto3";

package google.spanner.v1;

import "google/protobuf/struct.proto";
import "google/api/annotations.proto";
import "google/protobuf/struct.proto";

option csharp_namespace = "Google.Cloud.Spanner.V1";
option go_package = "google.golang.org/genproto/googleapis/spanner/v1;spanner";
Expand All @@ -29,6 +29,24 @@ option ruby_package = "Google::Cloud::Spanner::V1";

// Node information for nodes appearing in a [QueryPlan.plan_nodes][google.spanner.v1.QueryPlan.plan_nodes].
message PlanNode {
// The kind of [PlanNode][google.spanner.v1.PlanNode]. Distinguishes between the two different kinds of
// nodes that can appear in a query plan.
enum Kind {
// Not specified.
KIND_UNSPECIFIED = 0;

// Denotes a Relational operator node in the expression tree. Relational
// operators represent iterative processing of rows during query execution.
// For example, a `TableScan` operation that reads rows from a table.
RELATIONAL = 1;

// Denotes a Scalar node in the expression tree. Scalar nodes represent
// non-iterable entities in the query plan. For example, constants or
// arithmetic operators appearing inside predicate expressions or references
// to column names.
SCALAR = 2;
}

// Metadata associated with a parent-child relationship appearing in a
// [PlanNode][google.spanner.v1.PlanNode].
message ChildLink {
Expand Down Expand Up @@ -66,24 +84,6 @@ message PlanNode {
map<string, int32> subqueries = 2;
}

// The kind of [PlanNode][google.spanner.v1.PlanNode]. Distinguishes between the two different kinds of
// nodes that can appear in a query plan.
enum Kind {
// Not specified.
KIND_UNSPECIFIED = 0;

// Denotes a Relational operator node in the expression tree. Relational
// operators represent iterative processing of rows during query execution.
// For example, a `TableScan` operation that reads rows from a table.
RELATIONAL = 1;

// Denotes a Scalar node in the expression tree. Scalar nodes represent
// non-iterable entities in the query plan. For example, constants or
// arithmetic operators appearing inside predicate expressions or references
// to column names.
SCALAR = 2;
}

// The `PlanNode`'s index in [node list][google.spanner.v1.QueryPlan.plan_nodes].
int32 index = 1;

Expand Down
3 changes: 2 additions & 1 deletion google/spanner/v1/result_set.proto
Expand Up @@ -16,11 +16,12 @@ syntax = "proto3";

package google.spanner.v1;

import "google/api/annotations.proto";
import "google/protobuf/struct.proto";
import "google/spanner/v1/commit_response.proto";
import "google/spanner/v1/query_plan.proto";
import "google/spanner/v1/transaction.proto";
import "google/spanner/v1/type.proto";
import "google/api/annotations.proto";

option cc_enable_arenas = true;
option csharp_namespace = "Google.Cloud.Spanner.V1";
Expand Down
34 changes: 18 additions & 16 deletions google/spanner/v1/spanner.proto
Expand Up @@ -16,7 +16,6 @@ syntax = "proto3";

package google.spanner.v1;

import public "google/spanner/v1/commit_response.proto";
import "google/api/annotations.proto";
import "google/api/client.proto";
import "google/api/field_behavior.proto";
Expand All @@ -25,6 +24,7 @@ import "google/protobuf/empty.proto";
import "google/protobuf/struct.proto";
import "google/protobuf/timestamp.proto";
import "google/rpc/status.proto";
import public "google/spanner/v1/commit_response.proto";
import "google/spanner/v1/keys.proto";
import "google/spanner/v1/mutation.proto";
import "google/spanner/v1/result_set.proto";
Expand Down Expand Up @@ -469,24 +469,40 @@ message RequestOptions {
// Legal characters for `request_tag` values are all printable characters
// (ASCII 32 - 126) and the length of a request_tag is limited to 50
// characters. Values that exceed this limit are truncated.
// Any leading underscore (_) characters will be removed from the string.
string request_tag = 2;

// A tag used for statistics collection about this transaction.
// Both request_tag and transaction_tag can be specified for a read or query
// that belongs to a transaction.
// The value of transaction_tag should be the same for all requests belonging
// to the same transaction.
// If this request doesnt belong to any transaction, transaction_tag will be
// If this request doesn't belong to any transaction, transaction_tag will be
// ignored.
// Legal characters for `transaction_tag` values are all printable characters
// (ASCII 32 - 126) and the length of a transaction_tag is limited to 50
// characters. Values that exceed this limit are truncated.
// Any leading underscore (_) characters will be removed from the string.
string transaction_tag = 3;
}

// The request for [ExecuteSql][google.spanner.v1.Spanner.ExecuteSql] and
// [ExecuteStreamingSql][google.spanner.v1.Spanner.ExecuteStreamingSql].
message ExecuteSqlRequest {
// Mode in which the statement must be processed.
enum QueryMode {
// The default mode. Only the statement 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;
}

// Query optimizer configuration.
message QueryOptions {
// An option to control the selection of optimizer version.
Expand Down Expand Up @@ -540,20 +556,6 @@ message ExecuteSqlRequest {
string optimizer_statistics_package = 2;
}

// Mode in which the statement must be processed.
enum QueryMode {
// The default mode. Only the statement 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;
}

// Required. The session in which the SQL query should be performed.
string session = 1 [
(google.api.field_behavior) = REQUIRED,
Expand Down

0 comments on commit b0c104f

Please sign in to comment.