TCLIService.thrift 31 KB

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