translation_service.proto 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  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. syntax = "proto3";
  15. package google.cloud.bigquery.migration.v2alpha;
  16. import "google/api/annotations.proto";
  17. import "google/api/client.proto";
  18. import "google/api/field_behavior.proto";
  19. import "google/api/resource.proto";
  20. option csharp_namespace = "Google.Cloud.BigQuery.Migration.V2Alpha";
  21. option go_package = "google.golang.org/genproto/googleapis/cloud/bigquery/migration/v2alpha;migration";
  22. option java_multiple_files = true;
  23. option java_outer_classname = "TranslationServiceProto";
  24. option java_package = "com.google.cloud.bigquery.migration.v2alpha";
  25. option php_namespace = "Google\\Cloud\\BigQuery\\Migration\\V2alpha";
  26. // Provides other SQL dialects to GoogleSQL translation operations.
  27. service SqlTranslationService {
  28. option (google.api.default_host) = "bigquerymigration.googleapis.com";
  29. option (google.api.oauth_scopes) = "https://www.googleapis.com/auth/cloud-platform";
  30. // Translates input queries from source dialects to GoogleSQL.
  31. rpc TranslateQuery(TranslateQueryRequest) returns (TranslateQueryResponse) {
  32. option (google.api.http) = {
  33. post: "/v2alpha/{parent=projects/*/locations/*}:translateQuery"
  34. body: "*"
  35. };
  36. option (google.api.method_signature) = "parent,source_dialect,query";
  37. }
  38. }
  39. // The request of translating a SQL query to Standard SQL.
  40. message TranslateQueryRequest {
  41. // Supported SQL translation source dialects.
  42. enum SqlTranslationSourceDialect {
  43. // SqlTranslationSourceDialect not specified.
  44. SQL_TRANSLATION_SOURCE_DIALECT_UNSPECIFIED = 0;
  45. // Teradata SQL.
  46. TERADATA = 1;
  47. }
  48. // Required. The name of the project to which this translation request belongs.
  49. // Example: `projects/foo/locations/bar`
  50. string parent = 1 [
  51. (google.api.field_behavior) = REQUIRED,
  52. (google.api.resource_reference) = {
  53. type: "locations.googleapis.com/Location"
  54. }
  55. ];
  56. // Required. The source SQL dialect of `queries`.
  57. SqlTranslationSourceDialect source_dialect = 2 [(google.api.field_behavior) = REQUIRED];
  58. // Required. The query to be translated.
  59. string query = 3 [(google.api.field_behavior) = REQUIRED];
  60. }
  61. // The response of translating a SQL query to Standard SQL.
  62. message TranslateQueryResponse {
  63. // Output only. Immutable. The unique identifier for the SQL translation job.
  64. // Example: `projects/123/locations/us/translation/1234`
  65. string translation_job = 4 [
  66. (google.api.field_behavior) = OUTPUT_ONLY,
  67. (google.api.field_behavior) = IMMUTABLE
  68. ];
  69. // The translated result. This will be empty if the translation fails.
  70. string translated_query = 1;
  71. // The list of errors encountered during the translation, if present.
  72. repeated SqlTranslationError errors = 2;
  73. // The list of warnings encountered during the translation, if present,
  74. // indicates non-semantically correct translation.
  75. repeated SqlTranslationWarning warnings = 3;
  76. }
  77. // Structured error object capturing the error message and the location in the
  78. // source text where the error occurs.
  79. message SqlTranslationErrorDetail {
  80. // Specifies the row from the source text where the error occurred.
  81. int64 row = 1;
  82. // Specifie the column from the source texts where the error occurred.
  83. int64 column = 2;
  84. // A human-readable description of the error.
  85. string message = 3;
  86. }
  87. // The detailed error object if the SQL translation job fails.
  88. message SqlTranslationError {
  89. // The error type of the SQL translation job.
  90. enum SqlTranslationErrorType {
  91. // SqlTranslationErrorType not specified.
  92. SQL_TRANSLATION_ERROR_TYPE_UNSPECIFIED = 0;
  93. // Failed to parse the input text as a SQL query.
  94. SQL_PARSE_ERROR = 1;
  95. // Found unsupported functions in the input SQL query that are not able to
  96. // translate.
  97. UNSUPPORTED_SQL_FUNCTION = 2;
  98. }
  99. // The type of SQL translation error.
  100. SqlTranslationErrorType error_type = 1;
  101. // Specifies the details of the error, including the error message and
  102. // location from the source text.
  103. SqlTranslationErrorDetail error_detail = 2;
  104. }
  105. // The detailed warning object if the SQL translation job is completed but not
  106. // semantically correct.
  107. message SqlTranslationWarning {
  108. // Specifies the details of the warning, including the warning message and
  109. // location from the source text.
  110. SqlTranslationErrorDetail warning_detail = 1;
  111. }