beeswax.thrift 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152
  1. /*
  2. * Licensed to Cloudera, Inc. under one
  3. * or more contributor license agreements. See the NOTICE file
  4. * distributed with this work for additional information
  5. * regarding copyright ownership. Cloudera, Inc. licenses this file
  6. * to you under the Apache License, Version 2.0 (the
  7. * "License"); you may not use this file except in compliance
  8. * with the License. You may obtain a copy of the License at
  9. *
  10. * http://www.apache.org/licenses/LICENSE-2.0
  11. *
  12. * Unless required by applicable law or agreed to in writing, software
  13. * distributed under the License is distributed on an "AS IS" BASIS,
  14. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  15. * See the License for the specific language governing permissions and
  16. * limitations under the License.
  17. *
  18. * Interface for interacting with Beeswax Server
  19. */
  20. namespace java com.cloudera.beeswax.api
  21. namespace py beeswaxd
  22. include "hive_metastore.thrift"
  23. // A Query
  24. struct Query {
  25. 1: string query;
  26. // A list of HQL commands to execute before the query.
  27. // This is typically defining UDFs, setting settings, and loading resources.
  28. 3: list<string> configuration;
  29. // User and groups to "act as" for purposes of Hadoop.
  30. 4: string hadoop_user;
  31. 5: list<string> hadoop_groups;
  32. }
  33. typedef string LogContextId
  34. enum QueryState {
  35. CREATED,
  36. INITIALIZED,
  37. COMPILED,
  38. RUNNING,
  39. FINISHED,
  40. EXCEPTION
  41. }
  42. struct QueryHandle {
  43. 1: string id;
  44. 2: LogContextId log_context;
  45. }
  46. struct QueryExplanation {
  47. 1: string textual
  48. }
  49. struct Results {
  50. // If set, data is valid. Otherwise, results aren't ready yet.
  51. 1: bool ready,
  52. // Columns for the results
  53. 2: list<string> columns,
  54. // A set of results
  55. 3: list<string> data,
  56. // The starting row of the results
  57. 4: i64 start_row,
  58. // Whether there are more results to fetch
  59. 5: bool has_more
  60. }
  61. /**
  62. * Metadata information about the results.
  63. * Applicable only for SELECT.
  64. */
  65. struct ResultsMetadata {
  66. /** The schema of the results */
  67. 1: hive_metastore.Schema schema,
  68. /** The directory containing the results. Not applicable for partition table. */
  69. 2: string table_dir,
  70. /** If the results are straight from an existing table, the table name. */
  71. 3: string in_tablename,
  72. /** Field delimiter */
  73. 4: string delim,
  74. }
  75. exception BeeswaxException {
  76. 1: string message,
  77. // Use get_log(log_context) to retrieve any log related to this exception
  78. 2: LogContextId log_context,
  79. // (Optional) The QueryHandle that caused this exception
  80. 3: QueryHandle handle
  81. }
  82. exception QueryNotFoundException {
  83. }
  84. /** Represents a Hadoop-style configuration variable. */
  85. struct ConfigVariable {
  86. 1: string key,
  87. 2: string value,
  88. 3: string description
  89. }
  90. service BeeswaxService {
  91. /**
  92. * Submit a query and return a handle (QueryHandle). The query runs asynchronously.
  93. */
  94. QueryHandle query(1:Query query) throws(1:BeeswaxException error),
  95. /**
  96. * Get the query plan for a query.
  97. */
  98. QueryExplanation explain(1:Query query)
  99. throws(1:BeeswaxException error),
  100. /**
  101. * Get the results of a query. This is non-blocking. Caller should check
  102. * Results.ready to determine if the results are in yet.
  103. */
  104. Results fetch(1:QueryHandle query_id, 2:bool start_over) throws(1:QueryNotFoundException error, 2:BeeswaxException error2),
  105. /**
  106. * Get the state of the query
  107. */
  108. QueryState get_state(1:QueryHandle handle) throws(1:QueryNotFoundException error),
  109. /**
  110. * Get the result metadata
  111. */
  112. ResultsMetadata get_results_metadata(1:QueryHandle handle)
  113. throws(1:QueryNotFoundException error),
  114. /**
  115. * Used to test connection to server. A "noop" command.
  116. */
  117. string echo(1:string s)
  118. /**
  119. * Returns a string representation of the configuration object being used.
  120. * Handy for debugging.
  121. */
  122. string dump_config()
  123. /**
  124. * Get the log messages related to the given context.
  125. */
  126. string get_log(1:LogContextId context) throws(1:QueryNotFoundException error)
  127. /*
  128. * Returns "default" configuration.
  129. */
  130. list<ConfigVariable> get_default_configuration(1:bool include_hadoop)
  131. }