cli_service.thrift 26 KB

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