1// Copyright 2020 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.dataqna.v1alpha; 18 19import "google/api/field_behavior.proto"; 20import "google/api/resource.proto"; 21import "google/cloud/dataqna/v1alpha/annotated_string.proto"; 22import "google/protobuf/any.proto"; 23import "google/protobuf/timestamp.proto"; 24import "google/rpc/status.proto"; 25 26option csharp_namespace = "Google.Cloud.DataQnA.V1Alpha"; 27option go_package = "cloud.google.com/go/dataqna/apiv1alpha/dataqnapb;dataqnapb"; 28option java_multiple_files = true; 29option java_outer_classname = "QuestionProto"; 30option java_package = "com.google.cloud.dataqna.v1alpha"; 31option php_namespace = "Google\\Cloud\\DataQnA\\V1alpha"; 32option ruby_package = "Google::Cloud::DataQnA::V1alpha"; 33 34// The question resource represents a natural language query, its settings, 35// understanding generated by the system, and answer retrieval status. 36// A question cannot be modified. 37message Question { 38 option (google.api.resource) = { 39 type: "dataqna.googleapis.com/Question" 40 pattern: "projects/{project}/locations/{location}/questions/{question}" 41 }; 42 43 // Output only. Immutable. The unique identifier for the Question. The ID is server-generated. 44 // Example: `projects/foo/locations/bar/questions/123` 45 string name = 1 [ 46 (google.api.field_behavior) = OUTPUT_ONLY, 47 (google.api.field_behavior) = IMMUTABLE 48 ]; 49 50 // Required. Immutable. Scopes to be used for the question. A scope defines the relevant data set 51 // scope. It can be a reference to a specific data source or a collection of 52 // data sources. Currently, support is limited to a single BigQuery table. 53 // There must be exactly one `scopes` element. 54 // 55 // Example: 56 // `//bigquery.googleapis.com/projects/test-project/datasets/foo/tables/bar` 57 repeated string scopes = 2 [ 58 (google.api.field_behavior) = REQUIRED, 59 (google.api.field_behavior) = IMMUTABLE 60 ]; 61 62 // Required. Immutable. The query in natural language. 63 string query = 3 [ 64 (google.api.field_behavior) = REQUIRED, 65 (google.api.field_behavior) = IMMUTABLE 66 ]; 67 68 // A list of annotations to use instead of the default annotation of a data 69 // source (set in the data source reference resource). There must not be 70 // more than one annotation with the same data source reference. 71 repeated string data_source_annotations = 4; 72 73 // An error field explaining why interpretation failed. This is only populated 74 // if the interpretation failed. 75 // 76 // Note: This is different from getting a status error on the request itself. 77 // This is not a client or server error and the Question resource is still 78 // persisted, but the service could not interpret the question. Clients should 79 // present the error to the user so the user can rephrase the question. 80 InterpretError interpret_error = 5; 81 82 // A list of interpretations for this question. 83 repeated Interpretation interpretations = 6; 84 85 // Time when the question was created. 86 google.protobuf.Timestamp create_time = 7; 87 88 // Output only. The e-mail address of the user that created this question. 89 string user_email = 8 [(google.api.field_behavior) = OUTPUT_ONLY]; 90 91 // Input only. Immutable. Flags to request additional information for debugging purposes. 92 DebugFlags debug_flags = 9 [ 93 (google.api.field_behavior) = IMMUTABLE, 94 (google.api.field_behavior) = INPUT_ONLY 95 ]; 96 97 // Top level debug information. 98 // This will be stored as the type DebugInformation. 99 // Using Any so clients don't need to pull in anything 100 // inside the debug message. 101 google.protobuf.Any debug_info = 10; 102} 103 104// Details on the failure to interpret the question. 105message InterpretError { 106 // Details on interpretation failure. 107 message InterpretErrorDetails { 108 // Populated if parts of the query are unsupported. 109 InterpretUnsupportedDetails unsupported_details = 1; 110 111 // Populated if the query is incomplete. 112 InterpretIncompleteQueryDetails incomplete_query_details = 2; 113 114 // Populated if the query was too ambiguous. 115 InterpretAmbiguityDetails ambiguity_details = 3; 116 } 117 118 // Details about unsupported parts in a query. 119 message InterpretUnsupportedDetails { 120 // Unsupported operators. For example: median. 121 repeated string operators = 1; 122 123 // Unsupported intents. 124 repeated string intent = 2; 125 } 126 127 // Details about an incomplete query. 128 message InterpretIncompleteQueryDetails { 129 // List of missing interpret entities. 130 repeated InterpretEntity entities = 1; 131 } 132 133 // Details about a query that was too ambiguous. Currently, the message 134 // has no fields and its presence signals that there was ambiguity. 135 message InterpretAmbiguityDetails { 136 137 } 138 139 // The interpret error code provides an error category why the interpretation 140 // failed. 141 enum InterpretErrorCode { 142 // No interpret error code was specified. 143 INTERPRET_ERROR_CODE_UNSPECIFIED = 0; 144 145 // The query is not valid. 146 INVALID_QUERY = 1; 147 148 // The interpreter failed to understand the question. For example, because 149 // it was too ambiguous. 150 FAILED_TO_UNDERSTAND = 2; 151 152 // The interpreter could understand the question, but was not able to arrive 153 // at an answer. For example, because a requested operation is not 154 // supported. 155 FAILED_TO_ANSWER = 3; 156 } 157 158 // Error message explaining why this question could not be interpreted. 159 string message = 1; 160 161 // The code for the error category why the interpretation failed. 162 InterpretErrorCode code = 2; 163 164 // Details on interpretation failure. 165 InterpretErrorDetails details = 3; 166} 167 168// Information about the backend status (such as BigQuery) of the execution. 169message ExecutionInfo { 170 // Enum of possible job execution statuses. 171 enum JobExecutionState { 172 // No job execution was specified. 173 JOB_EXECUTION_STATE_UNSPECIFIED = 0; 174 175 // No job execution was requested, yet. 176 NOT_EXECUTED = 1; 177 178 // The job is running. 179 RUNNING = 2; 180 181 // The job completed successfully. 182 SUCCEEDED = 3; 183 184 // The job completed unsuccessfully. 185 FAILED = 4; 186 } 187 188 // Status returned by the backend when the job was created. 189 google.rpc.Status job_creation_status = 1; 190 191 // Status of the job execution. 192 JobExecutionState job_execution_state = 2; 193 194 // Time when the execution was triggered. 195 google.protobuf.Timestamp create_time = 3; 196 197 // BigQuery job information. 198 // Future versions will have different backends. Hence, clients must make sure 199 // they can handle it when this field is not populated. 200 BigQueryJob bigquery_job = 4; 201} 202 203// BigQuery job information. This can be used to query the BigQuery API and 204// retrieve the current job's status (using 205// [jobs.get](https://cloud.google.com/bigquery/docs/reference/rest/v2/jobs/get)). 206message BigQueryJob { 207 // The job ID. 208 string job_id = 1; 209 210 // The project ID of the job. 211 string project_id = 2; 212 213 // The location where the job is running. 214 string location = 3; 215} 216 217// An interpretation of a natural language query. 218message Interpretation { 219 // List of data sources used in the current understanding. 220 repeated string data_sources = 1; 221 222 // The level of confidence that one of the interpretations is correct. This is 223 // a value in the range [0, 1] where a value of 0.5 or below is to be 224 // considered a low confidence. 225 double confidence = 2; 226 227 // A list of unused phrases. Clients should display a Did You Mean (DYM) 228 // dialog if this is non-empty, even if this is the only interpretation. 229 repeated string unused_phrases = 3; 230 231 // Human readable representation of the query. 232 HumanReadable human_readable = 4; 233 234 // Information about the interpretation structure that helps to understand and 235 // visualize the response. 236 InterpretationStructure interpretation_structure = 5; 237 238 // Representation of the data query to be sent to the backend. 239 DataQuery data_query = 6; 240 241 // Information about the backend response. This is populated only if execution 242 // of an interpretation was requested. 243 ExecutionInfo execution_info = 7; 244} 245 246// Representation of the data query for the backend. 247// This is provided for informational purposes only. Clients should not use 248// it to send it to the backend directly, but rather use the `execute` RPC 249// to trigger the execution. Using the `execute` RPC is needed in order to 250// track the state of a question and report on it correctly to the data 251// administrators. 252message DataQuery { 253 // The generated SQL query to be sent to the backend. 254 string sql = 1; 255} 256 257// Human readable interpretation. 258message HumanReadable { 259 // Generated query explaining the interpretation. 260 AnnotatedString generated_interpretation = 1; 261 262 // Annotations on the original query. 263 AnnotatedString original_question = 2; 264} 265 266// Information about the interpretation structure that helps to understand and 267// visualize the response. 268message InterpretationStructure { 269 // Information about a column. 270 message ColumnInfo { 271 // The alias of the output column as used by the backend. For example, the 272 // field name in the schema provided in the query response in BigQuery. 273 string output_alias = 1; 274 275 // Human readable name of the output column. 276 string display_name = 2; 277 } 278 279 // Enumeration of visualzation types to use for query response data. 280 enum VisualizationType { 281 // No visualization type was specified. 282 VISUALIZATION_TYPE_UNSPECIFIED = 0; 283 284 // Show a table. 285 TABLE = 1; 286 287 // Show a [bar 288 // chart](https://developers.google.com/chart/interactive/docs/gallery/barchart). 289 BAR_CHART = 2; 290 291 // Show a [column 292 // chart](https://developers.google.com/chart/interactive/docs/gallery/columnchart). 293 COLUMN_CHART = 3; 294 295 // Show a 296 // [timeline](https://developers.google.com/chart/interactive/docs/gallery/timeline). 297 TIMELINE = 4; 298 299 // Show a [scatter 300 // plot](https://developers.google.com/chart/interactive/docs/gallery/scatterchart). 301 SCATTER_PLOT = 5; 302 303 // Show a [pie 304 // chart](https://developers.google.com/chart/interactive/docs/gallery/piechart). 305 PIE_CHART = 6; 306 307 // Show a [line 308 // chart](https://developers.google.com/chart/interactive/docs/gallery/linechart). 309 LINE_CHART = 7; 310 311 // Show an [area 312 // chart](https://developers.google.com/chart/interactive/docs/gallery/areachart). 313 AREA_CHART = 8; 314 315 // Show a [combo 316 // chart](https://developers.google.com/chart/interactive/docs/gallery/combochart). 317 COMBO_CHART = 9; 318 319 // Show a 320 // [histogram](https://developers.google.com/chart/interactive/docs/gallery/histogram). 321 HISTOGRAM = 10; 322 323 // This denotes queries when the user has not specified the particular type 324 // of chart and has mentioned only a generic chart name such as "Chart", 325 // "Plot", "Graph", etc. This will differentiate it from specific charting 326 // terms such as "Bar chart", "Pie chart", etc. 327 GENERIC_CHART = 11; 328 329 // The user tried to specify a chart type, but the interpreter could not 330 // understand the type. The client should display a generic chart and may 331 // give a hint to the user that the requested type was not understood. 332 CHART_NOT_UNDERSTOOD = 12; 333 } 334 335 // List of possible visualization types to apply for this interpretation. The 336 // order has no relevance. 337 repeated VisualizationType visualization_types = 1; 338 339 // Information about the output columns, that is, the columns that will be 340 // returned by the backend. 341 repeated ColumnInfo column_info = 2; 342} 343 344// Configuriation of debug flags. 345message DebugFlags { 346 // Whether to include the original VAQuery. 347 bool include_va_query = 1; 348 349 // Whether to include the original nested VAQuery. 350 bool include_nested_va_query = 2; 351 352 // Whether to include the original human interpretation strings generated 353 // by Analyza. 354 bool include_human_interpretation = 3; 355 356 // Whether to include the Aqua debug response. 357 bool include_aqua_debug_response = 4; 358 359 // The time in milliseconds from Unix epoch to be used 360 // to process the query. This is useful for testing 361 // the queries at different time period. 362 // If not set or time_override <= 0, then the current 363 // time is used. 364 int64 time_override = 5; 365 366 // Set to true if request is initiated by an internal Google user. 367 bool is_internal_google_user = 6; 368 369 // Determines whether cache needs to be ignored. If set to 370 // true, cache won't be queried and updated. 371 bool ignore_cache = 7; 372 373 // Whether to include the request/response pair from the call to the 374 // EntityIndex for SearchEntities. 375 bool include_search_entities_rpc = 8; 376 377 // Whether to include the request/response pair from the call to the 378 // Annotations service for ListColumnAnnotations. 379 bool include_list_column_annotations_rpc = 9; 380 381 // Whether to include the entity list passed to Analyza. 382 bool include_virtual_analyst_entities = 10; 383 384 // Whether to include the table list. 385 bool include_table_list = 11; 386 387 // Whether to include the domain list. 388 bool include_domain_list = 12; 389} 390 391// Query entities of an interpretation. 392enum InterpretEntity { 393 // No interpret entity was specified. 394 INTERPRET_ENTITY_UNSPECIFIED = 0; 395 396 // A dimenstion entity. 397 DIMENSION = 1; 398 399 // A metric entity. 400 METRIC = 2; 401} 402