1// Taken from https://github.com/apache/hive/blob/master/service-rpc/if/TCLIService.thrift 2// ---- 3// Licensed to the Apache Software Foundation (ASF) under one 4// or more contributor license agreements. See the NOTICE file 5// distributed with this work for additional information 6// regarding copyright ownership. The ASF licenses this file 7// to you under the Apache License, Version 2.0 (the 8// "License"); you may not use this file except in compliance 9// with the License. You may obtain a copy of the License at 10// 11// http://www.apache.org/licenses/LICENSE-2.0 12// 13// Unless required by applicable law or agreed to in writing, software 14// distributed under the License is distributed on an "AS IS" BASIS, 15// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16// See the License for the specific language governing permissions and 17// limitations under the License. 18 19// Coding Conventions for this file: 20// 21// Structs/Enums/Unions 22// * Struct, Enum, and Union names begin with a "T", 23// and use a capital letter for each new word, with no underscores. 24// * All fields should be declared as either optional or required. 25// 26// Functions 27// * Function names start with a capital letter and have a capital letter for 28// each new word, with no underscores. 29// * Each function should take exactly one parameter, named TFunctionNameReq, 30// and should return either void or TFunctionNameResp. This convention allows 31// incremental updates. 32// 33// Services 34// * Service names begin with the letter "T", use a capital letter for each 35// new word (with no underscores), and end with the word "Service". 36 37namespace java org.apache.hive.service.rpc.thrift 38namespace cpp apache.hive.service.rpc.thrift 39 40// List of protocol versions. A new token should be 41// added to the end of this list every time a change is made. 42enum TProtocolVersion { 43 HIVE_CLI_SERVICE_PROTOCOL_V1, 44 45 // V2 adds support for asynchronous execution 46 HIVE_CLI_SERVICE_PROTOCOL_V2 47 48 // V3 add varchar type, primitive type qualifiers 49 HIVE_CLI_SERVICE_PROTOCOL_V3 50 51 // V4 add decimal precision/scale, char type 52 HIVE_CLI_SERVICE_PROTOCOL_V4 53 54 // V5 adds error details when GetOperationStatus returns in error state 55 HIVE_CLI_SERVICE_PROTOCOL_V5 56 57 // V6 uses binary type for binary payload (was string) and uses columnar result set 58 HIVE_CLI_SERVICE_PROTOCOL_V6 59 60 // V7 adds support for delegation token based connection 61 HIVE_CLI_SERVICE_PROTOCOL_V7 62 63 // V8 adds support for interval types 64 HIVE_CLI_SERVICE_PROTOCOL_V8 65 66 // V9 adds support for serializing ResultSets in SerDe 67 HIVE_CLI_SERVICE_PROTOCOL_V9 68 69 // V10 adds support for in place updates via GetOperationStatus 70 HIVE_CLI_SERVICE_PROTOCOL_V10 71 72 // V11 adds timestamp with local time zone type 73 HIVE_CLI_SERVICE_PROTOCOL_V11 74} 75 76enum TTypeId { 77 BOOLEAN_TYPE, 78 TINYINT_TYPE, 79 SMALLINT_TYPE, 80 INT_TYPE, 81 BIGINT_TYPE, 82 FLOAT_TYPE, 83 DOUBLE_TYPE, 84 STRING_TYPE, 85 TIMESTAMP_TYPE, 86 BINARY_TYPE, 87 ARRAY_TYPE, 88 MAP_TYPE, 89 STRUCT_TYPE, 90 UNION_TYPE, 91 USER_DEFINED_TYPE, 92 DECIMAL_TYPE, 93 NULL_TYPE, 94 DATE_TYPE, 95 VARCHAR_TYPE, 96 CHAR_TYPE, 97 INTERVAL_YEAR_MONTH_TYPE, 98 INTERVAL_DAY_TIME_TYPE, 99 TIMESTAMPLOCALTZ_TYPE 100} 101 102const set<TTypeId> PRIMITIVE_TYPES = [ 103 TTypeId.BOOLEAN_TYPE, 104 TTypeId.TINYINT_TYPE, 105 TTypeId.SMALLINT_TYPE, 106 TTypeId.INT_TYPE, 107 TTypeId.BIGINT_TYPE, 108 TTypeId.FLOAT_TYPE, 109 TTypeId.DOUBLE_TYPE, 110 TTypeId.STRING_TYPE, 111 TTypeId.TIMESTAMP_TYPE, 112 TTypeId.BINARY_TYPE, 113 TTypeId.DECIMAL_TYPE, 114 TTypeId.NULL_TYPE, 115 TTypeId.DATE_TYPE, 116 TTypeId.VARCHAR_TYPE, 117 TTypeId.CHAR_TYPE, 118 TTypeId.INTERVAL_YEAR_MONTH_TYPE, 119 TTypeId.INTERVAL_DAY_TIME_TYPE, 120 TTypeId.TIMESTAMPLOCALTZ_TYPE 121] 122 123const set<TTypeId> COMPLEX_TYPES = [ 124 TTypeId.ARRAY_TYPE 125 TTypeId.MAP_TYPE 126 TTypeId.STRUCT_TYPE 127 TTypeId.UNION_TYPE 128 TTypeId.USER_DEFINED_TYPE 129] 130 131const set<TTypeId> COLLECTION_TYPES = [ 132 TTypeId.ARRAY_TYPE 133 TTypeId.MAP_TYPE 134] 135 136const map<TTypeId,string> TYPE_NAMES = { 137 TTypeId.BOOLEAN_TYPE: "BOOLEAN", 138 TTypeId.TINYINT_TYPE: "TINYINT", 139 TTypeId.SMALLINT_TYPE: "SMALLINT", 140 TTypeId.INT_TYPE: "INT", 141 TTypeId.BIGINT_TYPE: "BIGINT", 142 TTypeId.FLOAT_TYPE: "FLOAT", 143 TTypeId.DOUBLE_TYPE: "DOUBLE", 144 TTypeId.STRING_TYPE: "STRING", 145 TTypeId.TIMESTAMP_TYPE: "TIMESTAMP", 146 TTypeId.BINARY_TYPE: "BINARY", 147 TTypeId.ARRAY_TYPE: "ARRAY", 148 TTypeId.MAP_TYPE: "MAP", 149 TTypeId.STRUCT_TYPE: "STRUCT", 150 TTypeId.UNION_TYPE: "UNIONTYPE", 151 TTypeId.DECIMAL_TYPE: "DECIMAL", 152 TTypeId.NULL_TYPE: "NULL" 153 TTypeId.DATE_TYPE: "DATE" 154 TTypeId.VARCHAR_TYPE: "VARCHAR" 155 TTypeId.CHAR_TYPE: "CHAR" 156 TTypeId.INTERVAL_YEAR_MONTH_TYPE: "INTERVAL_YEAR_MONTH" 157 TTypeId.INTERVAL_DAY_TIME_TYPE: "INTERVAL_DAY_TIME" 158 TTypeId.TIMESTAMPLOCALTZ_TYPE: "TIMESTAMP WITH LOCAL TIME ZONE" 159} 160 161// Thrift does not support recursively defined types or forward declarations, 162// which makes it difficult to represent Hive's nested types. 163// To get around these limitations TTypeDesc employs a type list that maps 164// integer "pointers" to TTypeEntry objects. The following examples show 165// how different types are represented using this scheme: 166// 167// "INT": 168// TTypeDesc { 169// types = [ 170// TTypeEntry.primitive_entry { 171// type = INT_TYPE 172// } 173// ] 174// } 175// 176// "ARRAY<INT>": 177// TTypeDesc { 178// types = [ 179// TTypeEntry.array_entry { 180// object_type_ptr = 1 181// }, 182// TTypeEntry.primitive_entry { 183// type = INT_TYPE 184// } 185// ] 186// } 187// 188// "MAP<INT,STRING>": 189// TTypeDesc { 190// types = [ 191// TTypeEntry.map_entry { 192// key_type_ptr = 1 193// value_type_ptr = 2 194// }, 195// TTypeEntry.primitive_entry { 196// type = INT_TYPE 197// }, 198// TTypeEntry.primitive_entry { 199// type = STRING_TYPE 200// } 201// ] 202// } 203 204typedef i32 TTypeEntryPtr 205 206// Valid TTypeQualifiers key names 207const string CHARACTER_MAXIMUM_LENGTH = "characterMaximumLength" 208 209// Type qualifier key name for decimal 210const string PRECISION = "precision" 211const string SCALE = "scale" 212 213union TTypeQualifierValue { 214 1: optional i32 i32Value 215 2: optional string stringValue 216} 217 218// Type qualifiers for primitive type. 219struct TTypeQualifiers { 220 1: required map <string, TTypeQualifierValue> qualifiers 221} 222 223// Type entry for a primitive type. 224struct TPrimitiveTypeEntry { 225 // The primitive type token. This must satisfy the condition 226 // that type is in the PRIMITIVE_TYPES set. 227 1: required TTypeId type 228 2: optional TTypeQualifiers typeQualifiers 229} 230 231// Type entry for an ARRAY type. 232struct TArrayTypeEntry { 233 1: required TTypeEntryPtr objectTypePtr 234} 235 236// Type entry for a MAP type. 237struct TMapTypeEntry { 238 1: required TTypeEntryPtr keyTypePtr 239 2: required TTypeEntryPtr valueTypePtr 240} 241 242// Type entry for a STRUCT type. 243struct TStructTypeEntry { 244 1: required map<string, TTypeEntryPtr> nameToTypePtr 245} 246 247// Type entry for a UNIONTYPE type. 248struct TUnionTypeEntry { 249 1: required map<string, TTypeEntryPtr> nameToTypePtr 250} 251 252struct TUserDefinedTypeEntry { 253 // The fully qualified name of the class implementing this type. 254 1: required string typeClassName 255} 256 257// We use a union here since Thrift does not support inheritance. 258union TTypeEntry { 259 1: TPrimitiveTypeEntry primitiveEntry 260 2: TArrayTypeEntry arrayEntry 261 3: TMapTypeEntry mapEntry 262 4: TStructTypeEntry structEntry 263 5: TUnionTypeEntry unionEntry 264 6: TUserDefinedTypeEntry userDefinedTypeEntry 265} 266 267// Type descriptor for columns. 268struct TTypeDesc { 269 // The "top" type is always the first element of the list. 270 // If the top type is an ARRAY, MAP, STRUCT, or UNIONTYPE 271 // type, then subsequent elements represent nested types. 272 1: required list<TTypeEntry> types 273} 274 275// A result set column descriptor. 276struct TColumnDesc { 277 // The name of the column 278 1: required string columnName 279 280 // The type descriptor for this column 281 2: required TTypeDesc typeDesc 282 283 // The ordinal position of this column in the schema 284 3: required i32 position 285 286 4: optional string comment 287} 288 289// Metadata used to describe the schema (column names, types, comments) 290// of result sets. 291struct TTableSchema { 292 1: required list<TColumnDesc> columns 293} 294 295// A Boolean column value. 296struct TBoolValue { 297 // NULL if value is unset. 298 1: optional bool value 299} 300 301// A Byte column value. 302struct TByteValue { 303 // NULL if value is unset. 304 1: optional byte value 305} 306 307// A signed, 16 bit column value. 308struct TI16Value { 309 // NULL if value is unset 310 1: optional i16 value 311} 312 313// A signed, 32 bit column value 314struct TI32Value { 315 // NULL if value is unset 316 1: optional i32 value 317} 318 319// A signed 64 bit column value 320struct TI64Value { 321 // NULL if value is unset 322 1: optional i64 value 323} 324 325// A floating point 64 bit column value 326struct TDoubleValue { 327 // NULL if value is unset 328 1: optional double value 329} 330 331struct TStringValue { 332 // NULL if value is unset 333 1: optional string value 334} 335 336// A single column value in a result set. 337// Note that Hive's type system is richer than Thrift's, 338// so in some cases we have to map multiple Hive types 339// to the same Thrift type. On the client-side this is 340// disambiguated by looking at the Schema of the 341// result set. 342union TColumnValue { 343 1: TBoolValue boolVal // BOOLEAN 344 2: TByteValue byteVal // TINYINT 345 3: TI16Value i16Val // SMALLINT 346 4: TI32Value i32Val // INT 347 5: TI64Value i64Val // BIGINT, TIMESTAMP 348 6: TDoubleValue doubleVal // FLOAT, DOUBLE 349 7: TStringValue stringVal // STRING, LIST, MAP, STRUCT, UNIONTYPE, BINARY, DECIMAL, NULL, INTERVAL_YEAR_MONTH, INTERVAL_DAY_TIME 350} 351 352// Represents a row in a rowset. 353struct TRow { 354 1: required list<TColumnValue> colVals 355} 356 357struct TBoolColumn { 358 1: required list<bool> values 359 2: required binary nulls 360} 361 362struct TByteColumn { 363 1: required list<byte> values 364 2: required binary nulls 365} 366 367struct TI16Column { 368 1: required list<i16> values 369 2: required binary nulls 370} 371 372struct TI32Column { 373 1: required list<i32> values 374 2: required binary nulls 375} 376 377struct TI64Column { 378 1: required list<i64> values 379 2: required binary nulls 380} 381 382struct TDoubleColumn { 383 1: required list<double> values 384 2: required binary nulls 385} 386 387struct TStringColumn { 388 1: required list<string> values 389 2: required binary nulls 390} 391 392struct TBinaryColumn { 393 1: required list<binary> values 394 2: required binary nulls 395} 396 397// Note that Hive's type system is richer than Thrift's, 398// so in some cases we have to map multiple Hive types 399// to the same Thrift type. On the client-side this is 400// disambiguated by looking at the Schema of the 401// result set. 402union TColumn { 403 1: TBoolColumn boolVal // BOOLEAN 404 2: TByteColumn byteVal // TINYINT 405 3: TI16Column i16Val // SMALLINT 406 4: TI32Column i32Val // INT 407 5: TI64Column i64Val // BIGINT, TIMESTAMP 408 6: TDoubleColumn doubleVal // FLOAT, DOUBLE 409 7: TStringColumn stringVal // STRING, LIST, MAP, STRUCT, UNIONTYPE, DECIMAL, NULL 410 8: TBinaryColumn binaryVal // BINARY 411} 412 413// Represents a rowset 414struct TRowSet { 415 // The starting row offset of this rowset. 416 1: required i64 startRowOffset 417 2: required list<TRow> rows 418 3: optional list<TColumn> columns 419 4: optional binary binaryColumns 420 5: optional i32 columnCount 421} 422 423// The return status code contained in each response. 424enum TStatusCode { 425 SUCCESS_STATUS, 426 SUCCESS_WITH_INFO_STATUS, 427 STILL_EXECUTING_STATUS, 428 ERROR_STATUS, 429 INVALID_HANDLE_STATUS 430} 431 432// The return status of a remote request 433struct TStatus { 434 1: required TStatusCode statusCode 435 436 // If status is SUCCESS_WITH_INFO, info_msgs may be populated with 437 // additional diagnostic information. 438 2: optional list<string> infoMessages 439 440 // If status is ERROR, then the following fields may be set 441 3: optional string sqlState // as defined in the ISO/IEF CLI specification 442 4: optional i32 errorCode // internal error code 443 5: optional string errorMessage 444} 445 446// The state of an operation (i.e. a query or other 447// asynchronous operation that generates a result set) 448// on the server. 449enum TOperationState { 450 // The operation has been initialized 451 INITIALIZED_STATE, 452 453 // The operation is running. In this state the result 454 // set is not available. 455 RUNNING_STATE, 456 457 // The operation has completed. When an operation is in 458 // this state its result set may be fetched. 459 FINISHED_STATE, 460 461 // The operation was canceled by a client 462 CANCELED_STATE, 463 464 // The operation was closed by a client 465 CLOSED_STATE, 466 467 // The operation failed due to an error 468 ERROR_STATE, 469 470 // The operation is in an unrecognized state 471 UKNOWN_STATE, 472 473 // The operation is in an pending state 474 PENDING_STATE, 475 476 // The operation is in an timedout state 477 TIMEDOUT_STATE, 478} 479 480// A string identifier. This is interpreted literally. 481typedef string TIdentifier 482 483// A search pattern. 484// 485// Valid search pattern characters: 486// '_': Any single character. 487// '%': Any sequence of zero or more characters. 488// '\': Escape character used to include special characters, 489// e.g. '_', '%', '\'. If a '\' precedes a non-special 490// character it has no special meaning and is interpreted 491// literally. 492typedef string TPattern 493 494 495// A search pattern or identifier. Used as input 496// parameter for many of the catalog functions. 497typedef string TPatternOrIdentifier 498 499struct THandleIdentifier { 500 // 16 byte globally unique identifier 501 // This is the public ID of the handle and 502 // can be used for reporting. 503 1: required binary guid, 504 505 // 16 byte secret generated by the server 506 // and used to verify that the handle is not 507 // being hijacked by another user. 508 2: required binary secret, 509} 510 511// Client-side handle to persistent 512// session information on the server-side. 513struct TSessionHandle { 514 1: required THandleIdentifier sessionId 515} 516 517// The subtype of an OperationHandle. 518enum TOperationType { 519 EXECUTE_STATEMENT, 520 GET_TYPE_INFO, 521 GET_CATALOGS, 522 GET_SCHEMAS, 523 GET_TABLES, 524 GET_TABLE_TYPES, 525 GET_COLUMNS, 526 GET_FUNCTIONS, 527 UNKNOWN, 528 PROCEDURAL_SQL 529} 530 531// Client-side reference to a task running 532// asynchronously on the server. 533struct TOperationHandle { 534 1: required THandleIdentifier operationId 535 2: required TOperationType operationType 536 537 // If hasResultSet = TRUE, then this operation 538 // generates a result set that can be fetched. 539 // Note that the result set may be empty. 540 // 541 // If hasResultSet = FALSE, then this operation 542 // does not generate a result set, and calling 543 // GetResultSetMetadata or FetchResults against 544 // this OperationHandle will generate an error. 545 3: required bool hasResultSet 546 547 // For operations that don't generate result sets, 548 // modifiedRowCount is either: 549 // 550 // 1) The number of rows that were modified by 551 // the DML operation (e.g. number of rows inserted, 552 // number of rows deleted, etc). 553 // 554 // 2) 0 for operations that don't modify or add rows. 555 // 556 // 3) < 0 if the operation is capable of modifiying rows, 557 // but Hive is unable to determine how many rows were 558 // modified. For example, Hive's LOAD DATA command 559 // doesn't generate row count information because 560 // Hive doesn't inspect the data as it is loaded. 561 // 562 // modifiedRowCount is unset if the operation generates 563 // a result set. 564 4: optional double modifiedRowCount 565} 566 567 568// OpenSession() 569// 570// Open a session (connection) on the server against 571// which operations may be executed. 572struct TOpenSessionReq { 573 // The version of the HiveServer2 protocol that the client is using. 574 1: required TProtocolVersion client_protocol = TProtocolVersion.HIVE_CLI_SERVICE_PROTOCOL_V10 575 576 // Username and password for authentication. 577 // Depending on the authentication scheme being used, 578 // this information may instead be provided by a lower 579 // protocol layer, in which case these fields may be 580 // left unset. 581 2: optional string username 582 3: optional string password 583 584 // Configuration overlay which is applied when the session is 585 // first created. 586 4: optional map<string, string> configuration 587} 588 589struct TOpenSessionResp { 590 1: required TStatus status 591 592 // The protocol version that the server is using. 593 2: required TProtocolVersion serverProtocolVersion = TProtocolVersion.HIVE_CLI_SERVICE_PROTOCOL_V10 594 595 // Session Handle 596 3: optional TSessionHandle sessionHandle 597 598 // The configuration settings for this session. 599 4: optional map<string, string> configuration 600} 601 602struct TSetClientInfoReq { 603 1: required TSessionHandle sessionHandle, 604 2: optional map<string, string> configuration 605} 606 607struct TSetClientInfoResp { 608 1: required TStatus status 609} 610 611 612// CloseSession() 613// 614// Closes the specified session and frees any resources 615// currently allocated to that session. Any open 616// operations in that session will be canceled. 617struct TCloseSessionReq { 618 1: required TSessionHandle sessionHandle 619} 620 621struct TCloseSessionResp { 622 1: required TStatus status 623} 624 625 626 627enum TGetInfoType { 628 CLI_MAX_DRIVER_CONNECTIONS = 0, 629 CLI_MAX_CONCURRENT_ACTIVITIES = 1, 630 CLI_DATA_SOURCE_NAME = 2, 631 CLI_FETCH_DIRECTION = 8, 632 CLI_SERVER_NAME = 13, 633 CLI_SEARCH_PATTERN_ESCAPE = 14, 634 CLI_DBMS_NAME = 17, 635 CLI_DBMS_VER = 18, 636 CLI_ACCESSIBLE_TABLES = 19, 637 CLI_ACCESSIBLE_PROCEDURES = 20, 638 CLI_CURSOR_COMMIT_BEHAVIOR = 23, 639 CLI_DATA_SOURCE_READ_ONLY = 25, 640 CLI_DEFAULT_TXN_ISOLATION = 26, 641 CLI_IDENTIFIER_CASE = 28, 642 CLI_IDENTIFIER_QUOTE_CHAR = 29, 643 CLI_MAX_COLUMN_NAME_LEN = 30, 644 CLI_MAX_CURSOR_NAME_LEN = 31, 645 CLI_MAX_SCHEMA_NAME_LEN = 32, 646 CLI_MAX_CATALOG_NAME_LEN = 34, 647 CLI_MAX_TABLE_NAME_LEN = 35, 648 CLI_SCROLL_CONCURRENCY = 43, 649 CLI_TXN_CAPABLE = 46, 650 CLI_USER_NAME = 47, 651 CLI_TXN_ISOLATION_OPTION = 72, 652 CLI_INTEGRITY = 73, 653 CLI_GETDATA_EXTENSIONS = 81, 654 CLI_NULL_COLLATION = 85, 655 CLI_ALTER_TABLE = 86, 656 CLI_ORDER_BY_COLUMNS_IN_SELECT = 90, 657 CLI_SPECIAL_CHARACTERS = 94, 658 CLI_MAX_COLUMNS_IN_GROUP_BY = 97, 659 CLI_MAX_COLUMNS_IN_INDEX = 98, 660 CLI_MAX_COLUMNS_IN_ORDER_BY = 99, 661 CLI_MAX_COLUMNS_IN_SELECT = 100, 662 CLI_MAX_COLUMNS_IN_TABLE = 101, 663 CLI_MAX_INDEX_SIZE = 102, 664 CLI_MAX_ROW_SIZE = 104, 665 CLI_MAX_STATEMENT_LEN = 105, 666 CLI_MAX_TABLES_IN_SELECT = 106, 667 CLI_MAX_USER_NAME_LEN = 107, 668 CLI_OJ_CAPABILITIES = 115, 669 670 CLI_XOPEN_CLI_YEAR = 10000, 671 CLI_CURSOR_SENSITIVITY = 10001, 672 CLI_DESCRIBE_PARAMETER = 10002, 673 CLI_CATALOG_NAME = 10003, 674 CLI_COLLATION_SEQ = 10004, 675 CLI_MAX_IDENTIFIER_LEN = 10005, 676 CLI_ODBC_KEYWORDS = 10006 677} 678 679union TGetInfoValue { 680 1: string stringValue 681 2: i16 smallIntValue 682 3: i32 integerBitmask 683 4: i32 integerFlag 684 5: i32 binaryValue 685 6: i64 lenValue 686} 687 688// GetInfo() 689// 690// This function is based on ODBC's CLIGetInfo() function. 691// The function returns general information about the data source 692// using the same keys as ODBC. 693struct TGetInfoReq { 694 // The sesssion to run this request against 695 1: required TSessionHandle sessionHandle 696 697 2: required TGetInfoType infoType 698} 699 700struct TGetInfoResp { 701 1: required TStatus status 702 703 2: required TGetInfoValue infoValue 704} 705 706 707// ExecuteStatement() 708// 709// Execute a statement. 710// The returned OperationHandle can be used to check on the 711// status of the statement, and to fetch results once the 712// statement has finished executing. 713struct TExecuteStatementReq { 714 // The session to execute the statement against 715 1: required TSessionHandle sessionHandle 716 717 // The statement to be executed (DML, DDL, SET, etc) 718 2: required string statement 719 720 // Configuration properties that are overlayed on top of the 721 // the existing session configuration before this statement 722 // is executed. These properties apply to this statement 723 // only and will not affect the subsequent state of the Session. 724 3: optional map<string, string> confOverlay 725 726 // Execute asynchronously when runAsync is true 727 4: optional bool runAsync = false 728 729 // The number of seconds after which the query will timeout on the server 730 5: optional i64 queryTimeout = 0 731} 732 733struct TExecuteStatementResp { 734 1: required TStatus status 735 2: optional TOperationHandle operationHandle 736} 737 738// GetTypeInfo() 739// 740// Get information about types supported by the HiveServer instance. 741// The information is returned as a result set which can be fetched 742// using the OperationHandle provided in the response. 743// 744// Refer to the documentation for ODBC's CLIGetTypeInfo function for 745// the format of the result set. 746struct TGetTypeInfoReq { 747 // The session to run this request against. 748 1: required TSessionHandle sessionHandle 749} 750 751struct TGetTypeInfoResp { 752 1: required TStatus status 753 2: optional TOperationHandle operationHandle 754} 755 756 757// GetCatalogs() 758// 759// Returns the list of catalogs (databases) 760// Results are ordered by TABLE_CATALOG 761// 762// Resultset columns : 763// col1 764// name: TABLE_CAT 765// type: STRING 766// desc: Catalog name. NULL if not applicable. 767// 768struct TGetCatalogsReq { 769 // Session to run this request against 770 1: required TSessionHandle sessionHandle 771} 772 773struct TGetCatalogsResp { 774 1: required TStatus status 775 2: optional TOperationHandle operationHandle 776} 777 778 779// GetSchemas() 780// 781// Retrieves the schema names available in this database. 782// The results are ordered by TABLE_CATALOG and TABLE_SCHEM. 783// col1 784// name: TABLE_SCHEM 785// type: STRING 786// desc: schema name 787// col2 788// name: TABLE_CATALOG 789// type: STRING 790// desc: catalog name 791struct TGetSchemasReq { 792 // Session to run this request against 793 1: required TSessionHandle sessionHandle 794 795 // Name of the catalog. Must not contain a search pattern. 796 2: optional TIdentifier catalogName 797 798 // schema name or pattern 799 3: optional TPatternOrIdentifier schemaName 800} 801 802struct TGetSchemasResp { 803 1: required TStatus status 804 2: optional TOperationHandle operationHandle 805} 806 807 808// GetTables() 809// 810// Returns a list of tables with catalog, schema, and table 811// type information. The information is returned as a result 812// set which can be fetched using the OperationHandle 813// provided in the response. 814// Results are ordered by TABLE_TYPE, TABLE_CAT, TABLE_SCHEM, and TABLE_NAME 815// 816// Result Set Columns: 817// 818// col1 819// name: TABLE_CAT 820// type: STRING 821// desc: Catalog name. NULL if not applicable. 822// 823// col2 824// name: TABLE_SCHEM 825// type: STRING 826// desc: Schema name. 827// 828// col3 829// name: TABLE_NAME 830// type: STRING 831// desc: Table name. 832// 833// col4 834// name: TABLE_TYPE 835// type: STRING 836// desc: The table type, e.g. "TABLE", "VIEW", etc. 837// 838// col5 839// name: REMARKS 840// type: STRING 841// desc: Comments about the table 842// 843struct TGetTablesReq { 844 // Session to run this request against 845 1: required TSessionHandle sessionHandle 846 847 // Name of the catalog or a search pattern. 848 2: optional TPatternOrIdentifier catalogName 849 850 // Name of the schema or a search pattern. 851 3: optional TPatternOrIdentifier schemaName 852 853 // Name of the table or a search pattern. 854 4: optional TPatternOrIdentifier tableName 855 856 // List of table types to match 857 // e.g. "TABLE", "VIEW", "SYSTEM TABLE", "GLOBAL TEMPORARY", 858 // "LOCAL TEMPORARY", "ALIAS", "SYNONYM", etc. 859 5: optional list<string> tableTypes 860} 861 862struct TGetTablesResp { 863 1: required TStatus status 864 2: optional TOperationHandle operationHandle 865} 866 867 868// GetTableTypes() 869// 870// Returns the table types available in this database. 871// The results are ordered by table type. 872// 873// col1 874// name: TABLE_TYPE 875// type: STRING 876// desc: Table type name. 877struct TGetTableTypesReq { 878 // Session to run this request against 879 1: required TSessionHandle sessionHandle 880} 881 882struct TGetTableTypesResp { 883 1: required TStatus status 884 2: optional TOperationHandle operationHandle 885} 886 887 888// GetColumns() 889// 890// Returns a list of columns in the specified tables. 891// The information is returned as a result set which can be fetched 892// using the OperationHandle provided in the response. 893// Results are ordered by TABLE_CAT, TABLE_SCHEM, TABLE_NAME, 894// and ORDINAL_POSITION. 895// 896// Result Set Columns are the same as those for the ODBC CLIColumns 897// function. 898// 899struct TGetColumnsReq { 900 // Session to run this request against 901 1: required TSessionHandle sessionHandle 902 903 // Name of the catalog. Must not contain a search pattern. 904 2: optional TIdentifier catalogName 905 906 // Schema name or search pattern 907 3: optional TPatternOrIdentifier schemaName 908 909 // Table name or search pattern 910 4: optional TPatternOrIdentifier tableName 911 912 // Column name or search pattern 913 5: optional TPatternOrIdentifier columnName 914} 915 916struct TGetColumnsResp { 917 1: required TStatus status 918 2: optional TOperationHandle operationHandle 919} 920 921 922// GetFunctions() 923// 924// Returns a list of functions supported by the data source. The 925// behavior of this function matches 926// java.sql.DatabaseMetaData.getFunctions() both in terms of 927// inputs and outputs. 928// 929// Result Set Columns: 930// 931// col1 932// name: FUNCTION_CAT 933// type: STRING 934// desc: Function catalog (may be null) 935// 936// col2 937// name: FUNCTION_SCHEM 938// type: STRING 939// desc: Function schema (may be null) 940// 941// col3 942// name: FUNCTION_NAME 943// type: STRING 944// desc: Function name. This is the name used to invoke the function. 945// 946// col4 947// name: REMARKS 948// type: STRING 949// desc: Explanatory comment on the function. 950// 951// col5 952// name: FUNCTION_TYPE 953// type: SMALLINT 954// desc: Kind of function. One of: 955// * functionResultUnknown - Cannot determine if a return value or a table 956// will be returned. 957// * functionNoTable - Does not a return a table. 958// * functionReturnsTable - Returns a table. 959// 960// col6 961// name: SPECIFIC_NAME 962// type: STRING 963// desc: The name which uniquely identifies this function within its schema. 964// In this case this is the fully qualified class name of the class 965// that implements this function. 966// 967struct TGetFunctionsReq { 968 // Session to run this request against 969 1: required TSessionHandle sessionHandle 970 971 // A catalog name; must match the catalog name as it is stored in the 972 // database; "" retrieves those without a catalog; null means 973 // that the catalog name should not be used to narrow the search. 974 2: optional TIdentifier catalogName 975 976 // A schema name pattern; must match the schema name as it is stored 977 // in the database; "" retrieves those without a schema; null means 978 // that the schema name should not be used to narrow the search. 979 3: optional TPatternOrIdentifier schemaName 980 981 // A function name pattern; must match the function name as it is stored 982 // in the database. 983 4: required TPatternOrIdentifier functionName 984} 985 986struct TGetFunctionsResp { 987 1: required TStatus status 988 2: optional TOperationHandle operationHandle 989} 990 991struct TGetPrimaryKeysReq { 992 // Session to run this request against 993 1: required TSessionHandle sessionHandle 994 995 // Name of the catalog. 996 2: optional TIdentifier catalogName 997 998 // Name of the schema. 999 3: optional TIdentifier schemaName 1000 1001 // Name of the table. 1002 4: optional TIdentifier tableName 1003} 1004 1005struct TGetPrimaryKeysResp { 1006 1: required TStatus status 1007 2: optional TOperationHandle operationHandle 1008} 1009 1010struct TGetCrossReferenceReq { 1011 // Session to run this request against 1012 1: required TSessionHandle sessionHandle 1013 1014 // Name of the parent catalog. 1015 2: optional TIdentifier parentCatalogName 1016 1017 // Name of the parent schema. 1018 3: optional TIdentifier parentSchemaName 1019 1020 // Name of the parent table. 1021 4: optional TIdentifier parentTableName 1022 1023 // Name of the foreign catalog. 1024 5: optional TIdentifier foreignCatalogName 1025 1026 // Name of the foreign schema. 1027 6: optional TIdentifier foreignSchemaName 1028 1029 // Name of the foreign table. 1030 7: optional TIdentifier foreignTableName 1031} 1032 1033struct TGetCrossReferenceResp { 1034 1: required TStatus status 1035 2: optional TOperationHandle operationHandle 1036} 1037 1038// GetOperationStatus() 1039// 1040// Get the status of an operation running on the server. 1041struct TGetOperationStatusReq { 1042 // Session to run this request against 1043 1: required TOperationHandle operationHandle 1044 // optional arguments to get progress information 1045 2: optional bool getProgressUpdate 1046} 1047 1048struct TGetOperationStatusResp { 1049 1: required TStatus status 1050 2: optional TOperationState operationState 1051 1052 // If operationState is ERROR_STATE, then the following fields may be set 1053 // sqlState as defined in the ISO/IEF CLI specification 1054 3: optional string sqlState 1055 1056 // Internal error code 1057 4: optional i32 errorCode 1058 1059 // Error message 1060 5: optional string errorMessage 1061 1062 // List of statuses of sub tasks 1063 6: optional string taskStatus 1064 1065 // When was the operation started 1066 7: optional i64 operationStarted 1067 1068 // When was the operation completed 1069 8: optional i64 operationCompleted 1070 1071 // If the operation has the result 1072 9: optional bool hasResultSet 1073 1074 10: optional TProgressUpdateResp progressUpdateResponse 1075 1076 11: optional i64 numModifiedRows 1077} 1078 1079 1080// CancelOperation() 1081// 1082// Cancels processing on the specified operation handle and 1083// frees any resources which were allocated. 1084struct TCancelOperationReq { 1085 // Operation to cancel 1086 1: required TOperationHandle operationHandle 1087} 1088 1089struct TCancelOperationResp { 1090 1: required TStatus status 1091} 1092 1093 1094// CloseOperation() 1095// 1096// Given an operation in the FINISHED, CANCELED, 1097// or ERROR states, CloseOperation() will free 1098// all of the resources which were allocated on 1099// the server to service the operation. 1100struct TCloseOperationReq { 1101 1: required TOperationHandle operationHandle 1102} 1103 1104struct TCloseOperationResp { 1105 1: required TStatus status 1106} 1107 1108 1109// GetResultSetMetadata() 1110// 1111// Retrieves schema information for the specified operation 1112struct TGetResultSetMetadataReq { 1113 // Operation for which to fetch result set schema information 1114 1: required TOperationHandle operationHandle 1115} 1116 1117struct TGetResultSetMetadataResp { 1118 1: required TStatus status 1119 2: optional TTableSchema schema 1120} 1121 1122 1123enum TFetchOrientation { 1124 // Get the next rowset. The fetch offset is ignored. 1125 FETCH_NEXT, 1126 1127 // Get the previous rowset. The fetch offset is ignored. 1128 // NOT SUPPORTED 1129 FETCH_PRIOR, 1130 1131 // Return the rowset at the given fetch offset relative 1132 // to the curren rowset. 1133 // NOT SUPPORTED 1134 FETCH_RELATIVE, 1135 1136 // Return the rowset at the specified fetch offset. 1137 // NOT SUPPORTED 1138 FETCH_ABSOLUTE, 1139 1140 // Get the first rowset in the result set. 1141 FETCH_FIRST, 1142 1143 // Get the last rowset in the result set. 1144 // NOT SUPPORTED 1145 FETCH_LAST 1146} 1147 1148// FetchResults() 1149// 1150// Fetch rows from the server corresponding to 1151// a particular OperationHandle. 1152struct TFetchResultsReq { 1153 // Operation from which to fetch results. 1154 1: required TOperationHandle operationHandle 1155 1156 // The fetch orientation. For V1 this must be either 1157 // FETCH_NEXT or FETCH_FIRST. Defaults to FETCH_NEXT. 1158 2: required TFetchOrientation orientation = TFetchOrientation.FETCH_NEXT 1159 1160 // Max number of rows that should be returned in 1161 // the rowset. 1162 3: required i64 maxRows 1163 1164 // The type of a fetch results request. 0 represents Query output. 1 represents Log 1165 4: optional i16 fetchType = 0 1166} 1167 1168struct TFetchResultsResp { 1169 1: required TStatus status 1170 1171 // TRUE if there are more rows left to fetch from the server. 1172 2: optional bool hasMoreRows 1173 1174 // The rowset. This is optional so that we have the 1175 // option in the future of adding alternate formats for 1176 // representing result set data, e.g. delimited strings, 1177 // binary encoded, etc. 1178 3: optional TRowSet results 1179} 1180 1181// GetDelegationToken() 1182// Retrieve delegation token for the current user 1183struct TGetDelegationTokenReq { 1184 // session handle 1185 1: required TSessionHandle sessionHandle 1186 1187 // userid for the proxy user 1188 2: required string owner 1189 1190 // designated renewer userid 1191 3: required string renewer 1192} 1193 1194struct TGetDelegationTokenResp { 1195 // status of the request 1196 1: required TStatus status 1197 1198 // delegation token string 1199 2: optional string delegationToken 1200} 1201 1202// CancelDelegationToken() 1203// Cancel the given delegation token 1204struct TCancelDelegationTokenReq { 1205 // session handle 1206 1: required TSessionHandle sessionHandle 1207 1208 // delegation token to cancel 1209 2: required string delegationToken 1210} 1211 1212struct TCancelDelegationTokenResp { 1213 // status of the request 1214 1: required TStatus status 1215} 1216 1217// RenewDelegationToken() 1218// Renew the given delegation token 1219struct TRenewDelegationTokenReq { 1220 // session handle 1221 1: required TSessionHandle sessionHandle 1222 1223 // delegation token to renew 1224 2: required string delegationToken 1225} 1226 1227struct TRenewDelegationTokenResp { 1228 // status of the request 1229 1: required TStatus status 1230} 1231 1232enum TJobExecutionStatus { 1233 IN_PROGRESS, 1234 COMPLETE, 1235 NOT_AVAILABLE 1236} 1237 1238struct TProgressUpdateResp { 1239 1: required list<string> headerNames 1240 2: required list<list<string>> rows 1241 3: required double progressedPercentage 1242 4: required TJobExecutionStatus status 1243 5: required string footerSummary 1244 6: required i64 startTime 1245} 1246 1247struct TGetQueryIdReq { 1248 1: required TOperationHandle operationHandle 1249} 1250 1251struct TGetQueryIdResp { 1252 1: required string queryId 1253} 1254 1255service TCLIService { 1256 1257 TOpenSessionResp OpenSession(1:TOpenSessionReq req); 1258 1259 TCloseSessionResp CloseSession(1:TCloseSessionReq req); 1260 1261 TGetInfoResp GetInfo(1:TGetInfoReq req); 1262 1263 TExecuteStatementResp ExecuteStatement(1:TExecuteStatementReq req); 1264 1265 TGetTypeInfoResp GetTypeInfo(1:TGetTypeInfoReq req); 1266 1267 TGetCatalogsResp GetCatalogs(1:TGetCatalogsReq req); 1268 1269 TGetSchemasResp GetSchemas(1:TGetSchemasReq req); 1270 1271 TGetTablesResp GetTables(1:TGetTablesReq req); 1272 1273 TGetTableTypesResp GetTableTypes(1:TGetTableTypesReq req); 1274 1275 TGetColumnsResp GetColumns(1:TGetColumnsReq req); 1276 1277 TGetFunctionsResp GetFunctions(1:TGetFunctionsReq req); 1278 1279 TGetPrimaryKeysResp GetPrimaryKeys(1:TGetPrimaryKeysReq req); 1280 1281 TGetCrossReferenceResp GetCrossReference(1:TGetCrossReferenceReq req); 1282 1283 TGetOperationStatusResp GetOperationStatus(1:TGetOperationStatusReq req); 1284 1285 TCancelOperationResp CancelOperation(1:TCancelOperationReq req); 1286 1287 TCloseOperationResp CloseOperation(1:TCloseOperationReq req); 1288 1289 TGetResultSetMetadataResp GetResultSetMetadata(1:TGetResultSetMetadataReq req); 1290 1291 TFetchResultsResp FetchResults(1:TFetchResultsReq req); 1292 1293 TGetDelegationTokenResp GetDelegationToken(1:TGetDelegationTokenReq req); 1294 1295 TCancelDelegationTokenResp CancelDelegationToken(1:TCancelDelegationTokenReq req); 1296 1297 TRenewDelegationTokenResp RenewDelegationToken(1:TRenewDelegationTokenReq req); 1298 1299 TGetQueryIdResp GetQueryId(1:TGetQueryIdReq req); 1300 1301 TSetClientInfoResp SetClientInfo(1:TSetClientInfoReq req); 1302} 1303