xref: /aosp_15_r20/external/googleapis/google/cloud/bigquery/migration/v2alpha/translation_service.proto (revision d5c09012810ac0c9f33fe448fb6da8260d444cc9)
1// Copyright 2021 Google LLC
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7//     http://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14
15syntax = "proto3";
16
17package google.cloud.bigquery.migration.v2alpha;
18
19import "google/api/annotations.proto";
20import "google/api/client.proto";
21import "google/api/field_behavior.proto";
22import "google/api/resource.proto";
23
24option csharp_namespace = "Google.Cloud.BigQuery.Migration.V2Alpha";
25option go_package = "cloud.google.com/go/bigquery/migration/apiv2alpha/migrationpb;migrationpb";
26option java_multiple_files = true;
27option java_outer_classname = "TranslationServiceProto";
28option java_package = "com.google.cloud.bigquery.migration.v2alpha";
29option php_namespace = "Google\\Cloud\\BigQuery\\Migration\\V2alpha";
30
31// Provides other SQL dialects to GoogleSQL translation operations.
32service SqlTranslationService {
33  option (google.api.default_host) = "bigquerymigration.googleapis.com";
34  option (google.api.oauth_scopes) = "https://www.googleapis.com/auth/cloud-platform";
35
36  // Translates input queries from source dialects to GoogleSQL.
37  rpc TranslateQuery(TranslateQueryRequest) returns (TranslateQueryResponse) {
38    option (google.api.http) = {
39      post: "/v2alpha/{parent=projects/*/locations/*}:translateQuery"
40      body: "*"
41    };
42    option (google.api.method_signature) = "parent,source_dialect,query";
43  }
44}
45
46// The request of translating a SQL query to Standard SQL.
47message TranslateQueryRequest {
48  // Supported SQL translation source dialects.
49  enum SqlTranslationSourceDialect {
50    // SqlTranslationSourceDialect not specified.
51    SQL_TRANSLATION_SOURCE_DIALECT_UNSPECIFIED = 0;
52
53    // Teradata SQL.
54    TERADATA = 1;
55  }
56
57  // Required. The name of the project to which this translation request belongs.
58  // Example: `projects/foo/locations/bar`
59  string parent = 1 [
60    (google.api.field_behavior) = REQUIRED,
61    (google.api.resource_reference) = {
62      type: "locations.googleapis.com/Location"
63    }
64  ];
65
66  // Required. The source SQL dialect of `queries`.
67  SqlTranslationSourceDialect source_dialect = 2 [(google.api.field_behavior) = REQUIRED];
68
69  // Required. The query to be translated.
70  string query = 3 [(google.api.field_behavior) = REQUIRED];
71}
72
73// The response of translating a SQL query to Standard SQL.
74message TranslateQueryResponse {
75  // Output only. Immutable. The unique identifier for the SQL translation job.
76  // Example: `projects/123/locations/us/translation/1234`
77  string translation_job = 4 [
78    (google.api.field_behavior) = OUTPUT_ONLY,
79    (google.api.field_behavior) = IMMUTABLE
80  ];
81
82  // The translated result. This will be empty if the translation fails.
83  string translated_query = 1;
84
85  // The list of errors encountered during the translation, if present.
86  repeated SqlTranslationError errors = 2;
87
88  // The list of warnings encountered during the translation, if present,
89  // indicates non-semantically correct translation.
90  repeated SqlTranslationWarning warnings = 3;
91}
92
93// Structured error object capturing the error message and the location in the
94// source text where the error occurs.
95message SqlTranslationErrorDetail {
96  // Specifies the row from the source text where the error occurred.
97  int64 row = 1;
98
99  // Specifie the column from the source texts where the error occurred.
100  int64 column = 2;
101
102  // A human-readable description of the error.
103  string message = 3;
104}
105
106// The detailed error object if the SQL translation job fails.
107message SqlTranslationError {
108  // The error type of the SQL translation job.
109  enum SqlTranslationErrorType {
110    // SqlTranslationErrorType not specified.
111    SQL_TRANSLATION_ERROR_TYPE_UNSPECIFIED = 0;
112
113    // Failed to parse the input text as a SQL query.
114    SQL_PARSE_ERROR = 1;
115
116    // Found unsupported functions in the input SQL query that are not able to
117    // translate.
118    UNSUPPORTED_SQL_FUNCTION = 2;
119  }
120
121  // The type of SQL translation error.
122  SqlTranslationErrorType error_type = 1;
123
124  // Specifies the details of the error, including the error message and
125  // location from the source text.
126  SqlTranslationErrorDetail error_detail = 2;
127}
128
129// The detailed warning object if the SQL translation job is completed but not
130// semantically correct.
131message SqlTranslationWarning {
132  // Specifies the details of the warning, including the warning message and
133  // location from the source text.
134  SqlTranslationErrorDetail warning_detail = 1;
135}
136