TCLIService.thrift 27 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016
  1. // Licensed to the Apache Software Foundation (ASF) under one
  2. // or more contributor license agreements. See the NOTICE file
  3. // distributed with this work for additional information
  4. // regarding copyright ownership. The ASF licenses this file
  5. // to you under the Apache License, Version 2.0 (the
  6. // "License"); you may not use this file except in compliance
  7. // with the License. You may obtain a copy of the License at
  8. //
  9. // http://www.apache.org/licenses/LICENSE-2.0
  10. //
  11. // Unless required by applicable law or agreed to in writing, software
  12. // distributed under the License is distributed on an "AS IS" BASIS,
  13. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  14. // See the License for the specific language governing permissions and
  15. // limitations under the License.
  16. // Coding Conventions for this file:
  17. //
  18. // Structs/Enums/Unions
  19. // * Struct, Enum, and Union names begin with a "T",
  20. // and use a capital letter for each new word, with no underscores.
  21. // * All fields should be declared as either optional or required.
  22. //
  23. // Functions
  24. // * Function names start with a capital letter and have a capital letter for
  25. // each new word, with no underscores.
  26. // * Each function should take exactly one parameter, named TFunctionNameReq,
  27. // and should return either void or TFunctionNameResp. This convention allows
  28. // incremental updates.
  29. //
  30. // Services
  31. // * Service names begin with the letter "T", use a capital letter for each
  32. // new word (with no underscores), and end with the word "Service".
  33. namespace java org.apache.hive.service.cli.thrift
  34. namespace cpp apache.hive.service.cli.thrift
  35. // List of protocol versions. A new token should be
  36. // added to the end of this list every time a change is made.
  37. enum TProtocolVersion {
  38. HIVE_CLI_SERVICE_PROTOCOL_V1
  39. }
  40. enum TTypeId {
  41. BOOLEAN_TYPE,
  42. TINYINT_TYPE,
  43. SMALLINT_TYPE,
  44. INT_TYPE,
  45. BIGINT_TYPE,
  46. FLOAT_TYPE,
  47. DOUBLE_TYPE,
  48. STRING_TYPE,
  49. TIMESTAMP_TYPE,
  50. BINARY_TYPE,
  51. ARRAY_TYPE,
  52. MAP_TYPE,
  53. STRUCT_TYPE,
  54. UNION_TYPE,
  55. USER_DEFINED_TYPE,
  56. DECIMAL_TYPE
  57. }
  58. const set<TTypeId> PRIMITIVE_TYPES = [
  59. TTypeId.BOOLEAN_TYPE
  60. TTypeId.TINYINT_TYPE
  61. TTypeId.SMALLINT_TYPE
  62. TTypeId.INT_TYPE
  63. TTypeId.BIGINT_TYPE
  64. TTypeId.FLOAT_TYPE
  65. TTypeId.DOUBLE_TYPE
  66. TTypeId.STRING_TYPE
  67. TTypeId.TIMESTAMP_TYPE
  68. TTypeId.BINARY_TYPE,
  69. TTypeId.DECIMAL_TYPE
  70. ]
  71. const set<TTypeId> COMPLEX_TYPES = [
  72. TTypeId.ARRAY_TYPE
  73. TTypeId.MAP_TYPE
  74. TTypeId.STRUCT_TYPE
  75. TTypeId.UNION_TYPE
  76. TTypeId.USER_DEFINED_TYPE
  77. ]
  78. const set<TTypeId> COLLECTION_TYPES = [
  79. TTypeId.ARRAY_TYPE
  80. TTypeId.MAP_TYPE
  81. ]
  82. const map<TTypeId,string> TYPE_NAMES = {
  83. TTypeId.BOOLEAN_TYPE: "BOOLEAN",
  84. TTypeId.TINYINT_TYPE: "TINYINT",
  85. TTypeId.SMALLINT_TYPE: "SMALLINT",
  86. TTypeId.INT_TYPE: "INT",
  87. TTypeId.BIGINT_TYPE: "BIGINT",
  88. TTypeId.FLOAT_TYPE: "FLOAT",
  89. TTypeId.DOUBLE_TYPE: "DOUBLE",
  90. TTypeId.STRING_TYPE: "STRING",
  91. TTypeId.TIMESTAMP_TYPE: "TIMESTAMP",
  92. TTypeId.BINARY_TYPE: "BINARY",
  93. TTypeId.ARRAY_TYPE: "ARRAY",
  94. TTypeId.MAP_TYPE: "MAP",
  95. TTypeId.STRUCT_TYPE: "STRUCT",
  96. TTypeId.UNION_TYPE: "UNIONTYPE"
  97. TTypeId.DECIMAL_TYPE: "DECIMAL"
  98. }
  99. // Thrift does not support recursively defined types or forward declarations,
  100. // which makes it difficult to represent Hive's nested types.
  101. // To get around these limitations TTypeDesc employs a type list that maps
  102. // integer "pointers" to TTypeEntry objects. The following examples show
  103. // how different types are represented using this scheme:
  104. //
  105. // "INT":
  106. // TTypeDesc {
  107. // types = [
  108. // TTypeEntry.primitive_entry {
  109. // type = INT_TYPE
  110. // }
  111. // ]
  112. // }
  113. //
  114. // "ARRAY<INT>":
  115. // TTypeDesc {
  116. // types = [
  117. // TTypeEntry.array_entry {
  118. // object_type_ptr = 1
  119. // },
  120. // TTypeEntry.primitive_entry {
  121. // type = INT_TYPE
  122. // }
  123. // ]
  124. // }
  125. //
  126. // "MAP<INT,STRING>":
  127. // TTypeDesc {
  128. // types = [
  129. // TTypeEntry.map_entry {
  130. // key_type_ptr = 1
  131. // value_type_ptr = 2
  132. // },
  133. // TTypeEntry.primitive_entry {
  134. // type = INT_TYPE
  135. // },
  136. // TTypeEntry.primitive_entry {
  137. // type = STRING_TYPE
  138. // }
  139. // ]
  140. // }
  141. typedef i32 TTypeEntryPtr
  142. // Type entry for a primitive type.
  143. struct TPrimitiveTypeEntry {
  144. // The primitive type token. This must satisfy the condition
  145. // that type is in the PRIMITIVE_TYPES set.
  146. 1: required TTypeId type
  147. }
  148. // Type entry for an ARRAY type.
  149. struct TArrayTypeEntry {
  150. 1: required TTypeEntryPtr objectTypePtr
  151. }
  152. // Type entry for a MAP type.
  153. struct TMapTypeEntry {
  154. 1: required TTypeEntryPtr keyTypePtr
  155. 2: required TTypeEntryPtr valueTypePtr
  156. }
  157. // Type entry for a STRUCT type.
  158. struct TStructTypeEntry {
  159. 1: required map<string, TTypeEntryPtr> nameToTypePtr
  160. }
  161. // Type entry for a UNIONTYPE type.
  162. struct TUnionTypeEntry {
  163. 1: required map<string, TTypeEntryPtr> nameToTypePtr
  164. }
  165. struct TUserDefinedTypeEntry {
  166. // The fully qualified name of the class implementing this type.
  167. 1: required string typeClassName
  168. }
  169. // We use a union here since Thrift does not support inheritance.
  170. union TTypeEntry {
  171. 1: TPrimitiveTypeEntry primitiveEntry
  172. 2: TArrayTypeEntry arrayEntry
  173. 3: TMapTypeEntry mapEntry
  174. 4: TStructTypeEntry structEntry
  175. 5: TUnionTypeEntry unionEntry
  176. 6: TUserDefinedTypeEntry userDefinedTypeEntry
  177. }
  178. // Type descriptor for columns.
  179. struct TTypeDesc {
  180. // The "top" type is always the first element of the list.
  181. // If the top type is an ARRAY, MAP, STRUCT, or UNIONTYPE
  182. // type, then subsequent elements represent nested types.
  183. 1: required list<TTypeEntry> types
  184. }
  185. // A result set column descriptor.
  186. struct TColumnDesc {
  187. // The name of the column
  188. 1: required string columnName
  189. // The type descriptor for this column
  190. 2: required TTypeDesc typeDesc
  191. // The ordinal position of this column in the schema
  192. 3: required i32 position
  193. 4: optional string comment
  194. }
  195. // Metadata used to describe the schema (column names, types, comments)
  196. // of result sets.
  197. struct TTableSchema {
  198. 1: required list<TColumnDesc> columns
  199. }
  200. // A Boolean column value.
  201. struct TBoolValue {
  202. // NULL if value is unset.
  203. 1: optional bool value
  204. }
  205. // A Byte column value.
  206. struct TByteValue {
  207. // NULL if value is unset.
  208. 1: optional byte value
  209. }
  210. // A signed, 16 bit column value.
  211. struct TI16Value {
  212. // NULL if value is unset
  213. 1: optional i16 value
  214. }
  215. // A signed, 32 bit column value
  216. struct TI32Value {
  217. // NULL if value is unset
  218. 1: optional i32 value
  219. }
  220. // A signed 64 bit column value
  221. struct TI64Value {
  222. // NULL if value is unset
  223. 1: optional i64 value
  224. }
  225. // A floating point 64 bit column value
  226. struct TDoubleValue {
  227. // NULL if value is unset
  228. 1: optional double value
  229. }
  230. struct TStringValue {
  231. // NULL if value is unset
  232. 1: optional string value
  233. }
  234. union TColumn {
  235. 1: list<TBoolValue> boolColumn
  236. 2: list<TByteValue> byteColumn
  237. 3: list<TI16Value> i16Column
  238. 4: list<TI32Value> i32Column
  239. 5: list<TI64Value> i64Column
  240. 6: list<TDoubleValue> doubleColumn
  241. 7: list<TStringValue> stringColumn
  242. }
  243. // A single column value in a result set.
  244. // Note that Hive's type system is richer than Thrift's,
  245. // so in some cases we have to map multiple Hive types
  246. // to the same Thrift type. On the client-side this is
  247. // disambiguated by looking at the Schema of the
  248. // result set.
  249. union TColumnValue {
  250. 1: TBoolValue boolVal // BOOLEAN
  251. 2: TByteValue byteVal // TINYINT
  252. 3: TI16Value i16Val // SMALLINT
  253. 4: TI32Value i32Val // INT
  254. 5: TI64Value i64Val // BIGINT, TIMESTAMP
  255. 6: TDoubleValue doubleVal // FLOAT, DOUBLE
  256. 7: TStringValue stringVal // STRING, LIST, MAP, STRUCT, UNIONTYPE, BINARY, DECIMAL
  257. }
  258. // Represents a row in a rowset.
  259. struct TRow {
  260. 1: required list<TColumnValue> colVals
  261. }
  262. // Represents a rowset
  263. struct TRowSet {
  264. // The starting row offset of this rowset.
  265. 1: required i64 startRowOffset
  266. 2: required list<TRow> rows
  267. 3: optional list<TColumn> columns
  268. }
  269. // The return status code contained in each response.
  270. enum TStatusCode {
  271. SUCCESS_STATUS,
  272. SUCCESS_WITH_INFO_STATUS,
  273. STILL_EXECUTING_STATUS,
  274. ERROR_STATUS,
  275. INVALID_HANDLE_STATUS
  276. }
  277. // The return status of a remote request
  278. struct TStatus {
  279. 1: required TStatusCode statusCode
  280. // If status is SUCCESS_WITH_INFO, info_msgs may be populated with
  281. // additional diagnostic information.
  282. 2: optional list<string> infoMessages
  283. // If status is ERROR, then the following fields may be set
  284. 3: optional string sqlState // as defined in the ISO/IEF CLI specification
  285. 4: optional i32 errorCode // internal error code
  286. 5: optional string errorMessage
  287. }
  288. // The state of an operation (i.e. a query or other
  289. // asynchronous operation that generates a result set)
  290. // on the server.
  291. enum TOperationState {
  292. // The operation has been initialized
  293. INITIALIZED_STATE,
  294. // The operation is running. In this state the result
  295. // set is not available.
  296. RUNNING_STATE,
  297. // The operation has completed. When an operation is in
  298. // this state its result set may be fetched.
  299. FINISHED_STATE,
  300. // The operation was canceled by a client
  301. CANCELED_STATE,
  302. // The operation was closed by a client
  303. CLOSED_STATE,
  304. // The operation failed due to an error
  305. ERROR_STATE,
  306. // The operation is in an unrecognized state
  307. UKNOWN_STATE,
  308. }
  309. // A string identifier. This is interpreted literally.
  310. typedef string TIdentifier
  311. // A search pattern.
  312. //
  313. // Valid search pattern characters:
  314. // '_': Any single character.
  315. // '%': Any sequence of zero or more characters.
  316. // '\': Escape character used to include special characters,
  317. // e.g. '_', '%', '\'. If a '\' precedes a non-special
  318. // character it has no special meaning and is interpreted
  319. // literally.
  320. typedef string TPattern
  321. // A search pattern or identifier. Used as input
  322. // parameter for many of the catalog functions.
  323. typedef string TPatternOrIdentifier
  324. struct THandleIdentifier {
  325. // 16 byte globally unique identifier
  326. // This is the public ID of the handle and
  327. // can be used for reporting.
  328. 1: required binary guid,
  329. // 16 byte secret generated by the server
  330. // and used to verify that the handle is not
  331. // being hijacked by another user.
  332. 2: required binary secret,
  333. }
  334. // Client-side handle to persistent
  335. // session information on the server-side.
  336. struct TSessionHandle {
  337. 1: required THandleIdentifier sessionId
  338. }
  339. // The subtype of an OperationHandle.
  340. enum TOperationType {
  341. EXECUTE_STATEMENT,
  342. GET_TYPE_INFO,
  343. GET_CATALOGS,
  344. GET_SCHEMAS,
  345. GET_TABLES,
  346. GET_TABLE_TYPES,
  347. GET_COLUMNS,
  348. GET_FUNCTIONS,
  349. UNKNOWN,
  350. }
  351. // Client-side reference to a task running
  352. // asynchronously on the server.
  353. struct TOperationHandle {
  354. 1: required THandleIdentifier operationId
  355. 2: required TOperationType operationType
  356. // If hasResultSet = TRUE, then this operation
  357. // generates a result set that can be fetched.
  358. // Note that the result set may be empty.
  359. //
  360. // If hasResultSet = FALSE, then this operation
  361. // does not generate a result set, and calling
  362. // GetResultSetMetadata or FetchResults against
  363. // this OperationHandle will generate an error.
  364. 3: required bool hasResultSet
  365. // For operations that don't generate result sets,
  366. // modifiedRowCount is either:
  367. //
  368. // 1) The number of rows that were modified by
  369. // the DML operation (e.g. number of rows inserted,
  370. // number of rows deleted, etc).
  371. //
  372. // 2) 0 for operations that don't modify or add rows.
  373. //
  374. // 3) < 0 if the operation is capable of modifiying rows,
  375. // but Hive is unable to determine how many rows were
  376. // modified. For example, Hive's LOAD DATA command
  377. // doesn't generate row count information because
  378. // Hive doesn't inspect the data as it is loaded.
  379. //
  380. // modifiedRowCount is unset if the operation generates
  381. // a result set.
  382. 4: optional double modifiedRowCount
  383. }
  384. // OpenSession()
  385. //
  386. // Open a session (connection) on the server against
  387. // which operations may be executed.
  388. struct TOpenSessionReq {
  389. // The version of the HiveServer2 protocol that the client is using.
  390. 1: required TProtocolVersion client_protocol = TProtocolVersion.HIVE_CLI_SERVICE_PROTOCOL_V1
  391. // Username and password for authentication.
  392. // Depending on the authentication scheme being used,
  393. // this information may instead be provided by a lower
  394. // protocol layer, in which case these fields may be
  395. // left unset.
  396. 2: optional string username
  397. 3: optional string password
  398. // Configuration overlay which is applied when the session is
  399. // first created.
  400. 4: optional map<string, string> configuration
  401. }
  402. struct TOpenSessionResp {
  403. 1: required TStatus status
  404. // The protocol version that the server is using.
  405. 2: required TProtocolVersion serverProtocolVersion = TProtocolVersion.HIVE_CLI_SERVICE_PROTOCOL_V1
  406. // Session Handle
  407. 3: optional TSessionHandle sessionHandle
  408. // The configuration settings for this session.
  409. 4: optional map<string, string> configuration
  410. }
  411. // CloseSession()
  412. //
  413. // Closes the specified session and frees any resources
  414. // currently allocated to that session. Any open
  415. // operations in that session will be canceled.
  416. struct TCloseSessionReq {
  417. 1: required TSessionHandle sessionHandle
  418. }
  419. struct TCloseSessionResp {
  420. 1: required TStatus status
  421. }
  422. enum TGetInfoType {
  423. CLI_MAX_DRIVER_CONNECTIONS = 0,
  424. CLI_MAX_CONCURRENT_ACTIVITIES = 1,
  425. CLI_DATA_SOURCE_NAME = 2,
  426. CLI_FETCH_DIRECTION = 8,
  427. CLI_SERVER_NAME = 13,
  428. CLI_SEARCH_PATTERN_ESCAPE = 14,
  429. CLI_DBMS_NAME = 17,
  430. CLI_DBMS_VER = 18,
  431. CLI_ACCESSIBLE_TABLES = 19,
  432. CLI_ACCESSIBLE_PROCEDURES = 20,
  433. CLI_CURSOR_COMMIT_BEHAVIOR = 23,
  434. CLI_DATA_SOURCE_READ_ONLY = 25,
  435. CLI_DEFAULT_TXN_ISOLATION = 26,
  436. CLI_IDENTIFIER_CASE = 28,
  437. CLI_IDENTIFIER_QUOTE_CHAR = 29,
  438. CLI_MAX_COLUMN_NAME_LEN = 30,
  439. CLI_MAX_CURSOR_NAME_LEN = 31,
  440. CLI_MAX_SCHEMA_NAME_LEN = 32,
  441. CLI_MAX_CATALOG_NAME_LEN = 34,
  442. CLI_MAX_TABLE_NAME_LEN = 35,
  443. CLI_SCROLL_CONCURRENCY = 43,
  444. CLI_TXN_CAPABLE = 46,
  445. CLI_USER_NAME = 47,
  446. CLI_TXN_ISOLATION_OPTION = 72,
  447. CLI_INTEGRITY = 73,
  448. CLI_GETDATA_EXTENSIONS = 81,
  449. CLI_NULL_COLLATION = 85,
  450. CLI_ALTER_TABLE = 86,
  451. CLI_ORDER_BY_COLUMNS_IN_SELECT = 90,
  452. CLI_SPECIAL_CHARACTERS = 94,
  453. CLI_MAX_COLUMNS_IN_GROUP_BY = 97,
  454. CLI_MAX_COLUMNS_IN_INDEX = 98,
  455. CLI_MAX_COLUMNS_IN_ORDER_BY = 99,
  456. CLI_MAX_COLUMNS_IN_SELECT = 100,
  457. CLI_MAX_COLUMNS_IN_TABLE = 101,
  458. CLI_MAX_INDEX_SIZE = 102,
  459. CLI_MAX_ROW_SIZE = 104,
  460. CLI_MAX_STATEMENT_LEN = 105,
  461. CLI_MAX_TABLES_IN_SELECT = 106,
  462. CLI_MAX_USER_NAME_LEN = 107,
  463. CLI_OJ_CAPABILITIES = 115,
  464. CLI_XOPEN_CLI_YEAR = 10000,
  465. CLI_CURSOR_SENSITIVITY = 10001,
  466. CLI_DESCRIBE_PARAMETER = 10002,
  467. CLI_CATALOG_NAME = 10003,
  468. CLI_COLLATION_SEQ = 10004,
  469. CLI_MAX_IDENTIFIER_LEN = 10005,
  470. }
  471. union TGetInfoValue {
  472. 1: string stringValue
  473. 2: i16 smallIntValue
  474. 3: i32 integerBitmask
  475. 4: i32 integerFlag
  476. 5: i32 binaryValue
  477. 6: i64 lenValue
  478. }
  479. // GetInfo()
  480. //
  481. // This function is based on ODBC's CLIGetInfo() function.
  482. // The function returns general information about the data source
  483. // using the same keys as ODBC.
  484. struct TGetInfoReq {
  485. // The sesssion to run this request against
  486. 1: required TSessionHandle sessionHandle
  487. 2: required TGetInfoType infoType
  488. }
  489. struct TGetInfoResp {
  490. 1: required TStatus status
  491. 2: required TGetInfoValue infoValue
  492. }
  493. // ExecuteStatement()
  494. //
  495. // Execute a statement.
  496. // The returned OperationHandle can be used to check on the
  497. // status of the statement, and to fetch results once the
  498. // statement has finished executing.
  499. struct TExecuteStatementReq {
  500. // The session to exexcute the statement against
  501. 1: required TSessionHandle sessionHandle
  502. // The statement to be executed (DML, DDL, SET, etc)
  503. 2: required string statement
  504. // Configuration properties that are overlayed on top of the
  505. // the existing session configuration before this statement
  506. // is executed. These properties apply to this statement
  507. // only and will not affect the subsequent state of the Session.
  508. 3: optional map<string, string> confOverlay
  509. }
  510. struct TExecuteStatementResp {
  511. 1: required TStatus status
  512. 2: optional TOperationHandle operationHandle
  513. }
  514. // GetTypeInfo()
  515. //
  516. // Get information about types supported by the HiveServer instance.
  517. // The information is returned as a result set which can be fetched
  518. // using the OperationHandle provided in the response.
  519. //
  520. // Refer to the documentation for ODBC's CLIGetTypeInfo function for
  521. // the format of the result set.
  522. struct TGetTypeInfoReq {
  523. // The session to run this request against.
  524. 1: required TSessionHandle sessionHandle
  525. }
  526. struct TGetTypeInfoResp {
  527. 1: required TStatus status
  528. 2: optional TOperationHandle operationHandle
  529. }
  530. // GetCatalogs()
  531. //
  532. // Returns the list of catalogs (databases)
  533. // Results are ordered by TABLE_CATALOG
  534. //
  535. // Resultset columns :
  536. // col1
  537. // name: TABLE_CAT
  538. // type: STRING
  539. // desc: Catalog name. NULL if not applicable.
  540. //
  541. struct TGetCatalogsReq {
  542. // Session to run this request against
  543. 1: required TSessionHandle sessionHandle
  544. }
  545. struct TGetCatalogsResp {
  546. 1: required TStatus status
  547. 2: optional TOperationHandle operationHandle
  548. }
  549. // GetSchemas()
  550. //
  551. // Retrieves the schema names available in this database.
  552. // The results are ordered by TABLE_CATALOG and TABLE_SCHEM.
  553. // col1
  554. // name: TABLE_SCHEM
  555. // type: STRING
  556. // desc: schema name
  557. // col2
  558. // name: TABLE_CATALOG
  559. // type: STRING
  560. // desc: catalog name
  561. struct TGetSchemasReq {
  562. // Session to run this request against
  563. 1: required TSessionHandle sessionHandle
  564. // Name of the catalog. Must not contain a search pattern.
  565. 2: optional TIdentifier catalogName
  566. // schema name or pattern
  567. 3: optional TPatternOrIdentifier schemaName
  568. }
  569. struct TGetSchemasResp {
  570. 1: required TStatus status
  571. 2: optional TOperationHandle operationHandle
  572. }
  573. // GetTables()
  574. //
  575. // Returns a list of tables with catalog, schema, and table
  576. // type information. The information is returned as a result
  577. // set which can be fetched using the OperationHandle
  578. // provided in the response.
  579. // Results are ordered by TABLE_TYPE, TABLE_CAT, TABLE_SCHEM, and TABLE_NAME
  580. //
  581. // Result Set Columns:
  582. //
  583. // col1
  584. // name: TABLE_CAT
  585. // type: STRING
  586. // desc: Catalog name. NULL if not applicable.
  587. //
  588. // col2
  589. // name: TABLE_SCHEM
  590. // type: STRING
  591. // desc: Schema name.
  592. //
  593. // col3
  594. // name: TABLE_NAME
  595. // type: STRING
  596. // desc: Table name.
  597. //
  598. // col4
  599. // name: TABLE_TYPE
  600. // type: STRING
  601. // desc: The table type, e.g. "TABLE", "VIEW", etc.
  602. //
  603. // col5
  604. // name: REMARKS
  605. // type: STRING
  606. // desc: Comments about the table
  607. //
  608. struct TGetTablesReq {
  609. // Session to run this request against
  610. 1: required TSessionHandle sessionHandle
  611. // Name of the catalog or a search pattern.
  612. 2: optional TPatternOrIdentifier catalogName
  613. // Name of the schema or a search pattern.
  614. 3: optional TPatternOrIdentifier schemaName
  615. // Name of the table or a search pattern.
  616. 4: optional TPatternOrIdentifier tableName
  617. // List of table types to match
  618. // e.g. "TABLE", "VIEW", "SYSTEM TABLE", "GLOBAL TEMPORARY",
  619. // "LOCAL TEMPORARY", "ALIAS", "SYNONYM", etc.
  620. 5: optional list<string> tableTypes
  621. }
  622. struct TGetTablesResp {
  623. 1: required TStatus status
  624. 2: optional TOperationHandle operationHandle
  625. }
  626. // GetTableTypes()
  627. //
  628. // Returns the table types available in this database.
  629. // The results are ordered by table type.
  630. //
  631. // col1
  632. // name: TABLE_TYPE
  633. // type: STRING
  634. // desc: Table type name.
  635. struct TGetTableTypesReq {
  636. // Session to run this request against
  637. 1: required TSessionHandle sessionHandle
  638. }
  639. struct TGetTableTypesResp {
  640. 1: required TStatus status
  641. 2: optional TOperationHandle operationHandle
  642. }
  643. // GetColumns()
  644. //
  645. // Returns a list of columns in the specified tables.
  646. // The information is returned as a result set which can be fetched
  647. // using the OperationHandle provided in the response.
  648. // Results are ordered by TABLE_CAT, TABLE_SCHEM, TABLE_NAME,
  649. // and ORDINAL_POSITION.
  650. //
  651. // Result Set Columns are the same as those for the ODBC CLIColumns
  652. // function.
  653. //
  654. struct TGetColumnsReq {
  655. // Session to run this request against
  656. 1: required TSessionHandle sessionHandle
  657. // Name of the catalog. Must not contain a search pattern.
  658. 2: optional TIdentifier catalogName
  659. // Schema name or search pattern
  660. 3: optional TPatternOrIdentifier schemaName
  661. // Table name or search pattern
  662. 4: optional TPatternOrIdentifier tableName
  663. // Column name or search pattern
  664. 5: optional TPatternOrIdentifier columnName
  665. }
  666. struct TGetColumnsResp {
  667. 1: required TStatus status
  668. 2: optional TOperationHandle operationHandle
  669. }
  670. // GetFunctions()
  671. //
  672. // Returns a list of functions supported by the data source. The
  673. // behavior of this function matches
  674. // java.sql.DatabaseMetaData.getFunctions() both in terms of
  675. // inputs and outputs.
  676. //
  677. // Result Set Columns:
  678. //
  679. // col1
  680. // name: FUNCTION_CAT
  681. // type: STRING
  682. // desc: Function catalog (may be null)
  683. //
  684. // col2
  685. // name: FUNCTION_SCHEM
  686. // type: STRING
  687. // desc: Function schema (may be null)
  688. //
  689. // col3
  690. // name: FUNCTION_NAME
  691. // type: STRING
  692. // desc: Function name. This is the name used to invoke the function.
  693. //
  694. // col4
  695. // name: REMARKS
  696. // type: STRING
  697. // desc: Explanatory comment on the function.
  698. //
  699. // col5
  700. // name: FUNCTION_TYPE
  701. // type: SMALLINT
  702. // desc: Kind of function. One of:
  703. // * functionResultUnknown - Cannot determine if a return value or a table
  704. // will be returned.
  705. // * functionNoTable - Does not a return a table.
  706. // * functionReturnsTable - Returns a table.
  707. //
  708. // col6
  709. // name: SPECIFIC_NAME
  710. // type: STRING
  711. // desc: The name which uniquely identifies this function within its schema.
  712. // In this case this is the fully qualified class name of the class
  713. // that implements this function.
  714. //
  715. struct TGetFunctionsReq {
  716. // Session to run this request against
  717. 1: required TSessionHandle sessionHandle
  718. // A catalog name; must match the catalog name as it is stored in the
  719. // database; "" retrieves those without a catalog; null means
  720. // that the catalog name should not be used to narrow the search.
  721. 2: optional TIdentifier catalogName
  722. // A schema name pattern; must match the schema name as it is stored
  723. // in the database; "" retrieves those without a schema; null means
  724. // that the schema name should not be used to narrow the search.
  725. 3: optional TPatternOrIdentifier schemaName
  726. // A function name pattern; must match the function name as it is stored
  727. // in the database.
  728. 4: required TPatternOrIdentifier functionName
  729. }
  730. struct TGetFunctionsResp {
  731. 1: required TStatus status
  732. 2: optional TOperationHandle operationHandle
  733. }
  734. // GetOperationStatus()
  735. //
  736. // Get the status of an operation running on the server.
  737. struct TGetOperationStatusReq {
  738. // Session to run this request against
  739. 1: required TOperationHandle operationHandle
  740. }
  741. struct TGetOperationStatusResp {
  742. 1: required TStatus status
  743. 2: optional TOperationState operationState
  744. }
  745. // CancelOperation()
  746. //
  747. // Cancels processing on the specified operation handle and
  748. // frees any resources which were allocated.
  749. struct TCancelOperationReq {
  750. // Operation to cancel
  751. 1: required TOperationHandle operationHandle
  752. }
  753. struct TCancelOperationResp {
  754. 1: required TStatus status
  755. }
  756. // CloseOperation()
  757. //
  758. // Given an operation in the FINISHED, CANCELED,
  759. // or ERROR states, CloseOperation() will free
  760. // all of the resources which were allocated on
  761. // the server to service the operation.
  762. struct TCloseOperationReq {
  763. 1: required TOperationHandle operationHandle
  764. }
  765. struct TCloseOperationResp {
  766. 1: required TStatus status
  767. }
  768. // GetResultSetMetadata()
  769. //
  770. // Retrieves schema information for the specified operation
  771. struct TGetResultSetMetadataReq {
  772. // Operation for which to fetch result set schema information
  773. 1: required TOperationHandle operationHandle
  774. }
  775. struct TGetResultSetMetadataResp {
  776. 1: required TStatus status
  777. 2: optional TTableSchema schema
  778. }
  779. enum TFetchOrientation {
  780. // Get the next rowset. The fetch offset is ignored.
  781. FETCH_NEXT,
  782. // Get the previous rowset. The fetch offset is ignored.
  783. // NOT SUPPORTED
  784. FETCH_PRIOR,
  785. // Return the rowset at the given fetch offset relative
  786. // to the curren rowset.
  787. // NOT SUPPORTED
  788. FETCH_RELATIVE,
  789. // Return the rowset at the specified fetch offset.
  790. // NOT SUPPORTED
  791. FETCH_ABSOLUTE,
  792. // Get the first rowset in the result set.
  793. FETCH_FIRST,
  794. // Get the last rowset in the result set.
  795. // NOT SUPPORTED
  796. FETCH_LAST
  797. }
  798. // FetchResults()
  799. //
  800. // Fetch rows from the server corresponding to
  801. // a particular OperationHandle.
  802. struct TFetchResultsReq {
  803. // Operation from which to fetch results.
  804. 1: required TOperationHandle operationHandle
  805. // The fetch orientation. For V1 this must be either
  806. // FETCH_NEXT or FETCH_FIRST. Defaults to FETCH_NEXT.
  807. 2: required TFetchOrientation orientation = TFetchOrientation.FETCH_NEXT
  808. // Max number of rows that should be returned in
  809. // the rowset.
  810. 3: required i64 maxRows
  811. }
  812. struct TFetchResultsResp {
  813. 1: required TStatus status
  814. // TRUE if there are more rows left to fetch from the server.
  815. 2: optional bool hasMoreRows
  816. // The rowset. This is optional so that we have the
  817. // option in the future of adding alternate formats for
  818. // representing result set data, e.g. delimited strings,
  819. // binary encoded, etc.
  820. 3: optional TRowSet results
  821. }
  822. // GetLog()
  823. //
  824. // Fetch operation log from the server corresponding to
  825. // a particular OperationHandle.
  826. struct TGetLogReq {
  827. // Operation whose log is requested
  828. 1: required TOperationHandle operationHandle
  829. }
  830. struct TGetLogResp {
  831. 1: required TStatus status
  832. 2: required string log
  833. }
  834. service TCLIService {
  835. TOpenSessionResp OpenSession(1:TOpenSessionReq req);
  836. TCloseSessionResp CloseSession(1:TCloseSessionReq req);
  837. TGetInfoResp GetInfo(1:TGetInfoReq req);
  838. TExecuteStatementResp ExecuteStatement(1:TExecuteStatementReq req);
  839. TGetTypeInfoResp GetTypeInfo(1:TGetTypeInfoReq req);
  840. TGetCatalogsResp GetCatalogs(1:TGetCatalogsReq req);
  841. TGetSchemasResp GetSchemas(1:TGetSchemasReq req);
  842. TGetTablesResp GetTables(1:TGetTablesReq req);
  843. TGetTableTypesResp GetTableTypes(1:TGetTableTypesReq req);
  844. TGetColumnsResp GetColumns(1:TGetColumnsReq req);
  845. TGetFunctionsResp GetFunctions(1:TGetFunctionsReq req);
  846. TGetOperationStatusResp GetOperationStatus(1:TGetOperationStatusReq req);
  847. TCancelOperationResp CancelOperation(1:TCancelOperationReq req);
  848. TCloseOperationResp CloseOperation(1:TCloseOperationReq req);
  849. TGetResultSetMetadataResp GetResultSetMetadata(1:TGetResultSetMetadataReq req);
  850. TFetchResultsResp FetchResults(1:TFetchResultsReq req);
  851. TGetLogResp GetLog(1:TGetLogReq req);
  852. }