question.proto 13 KB

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