impala 0.1.6 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (84) hide show
  1. data/Rakefile +0 -2
  2. data/impala.gemspec +1 -2
  3. data/lib/impala.rb +1 -1
  4. data/lib/impala/cursor.rb +10 -4
  5. data/lib/impala/protocol/beeswax_constants.rb +2 -1
  6. data/lib/impala/protocol/beeswax_service.rb +46 -46
  7. data/lib/impala/protocol/beeswax_types.rb +31 -30
  8. data/lib/impala/protocol/cli_service_constants.rb +60 -0
  9. data/lib/impala/protocol/cli_service_types.rb +1452 -0
  10. data/lib/impala/protocol/facebook_service.rb +17 -17
  11. data/lib/impala/protocol/fb303_constants.rb +2 -1
  12. data/lib/impala/protocol/fb303_types.rb +3 -2
  13. data/lib/impala/protocol/hive_metastore_constants.rb +2 -1
  14. data/lib/impala/protocol/hive_metastore_types.rb +102 -101
  15. data/lib/impala/protocol/impala_hive_server2_service.rb +29 -0
  16. data/lib/impala/protocol/impala_service.rb +135 -18
  17. data/lib/impala/protocol/impala_service_constants.rb +2 -1
  18. data/lib/impala/protocol/impala_service_types.rb +54 -10
  19. data/lib/impala/protocol/status_constants.rb +2 -1
  20. data/lib/impala/protocol/status_types.rb +9 -7
  21. data/lib/impala/protocol/t_c_l_i_service.rb +948 -0
  22. data/lib/impala/protocol/thrift_hive_metastore.rb +507 -507
  23. data/lib/impala/version.rb +1 -1
  24. data/test/test_impala_connected.rb +93 -13
  25. data/thrift/ImpalaService.thrift +78 -6
  26. data/thrift/Status.thrift +2 -1
  27. data/thrift/beeswax.thrift +1 -1
  28. data/thrift/cli_service.thrift +1015 -0
  29. metadata +9 -75
  30. data/lib/impala/protocol/data_constants.rb +0 -12
  31. data/lib/impala/protocol/data_sinks_constants.rb +0 -12
  32. data/lib/impala/protocol/data_sinks_types.rb +0 -107
  33. data/lib/impala/protocol/data_types.rb +0 -77
  34. data/lib/impala/protocol/descriptors_constants.rb +0 -12
  35. data/lib/impala/protocol/descriptors_types.rb +0 -266
  36. data/lib/impala/protocol/exprs_constants.rb +0 -12
  37. data/lib/impala/protocol/exprs_types.rb +0 -345
  38. data/lib/impala/protocol/frontend_constants.rb +0 -12
  39. data/lib/impala/protocol/frontend_types.rb +0 -347
  40. data/lib/impala/protocol/impala_internal_service.rb +0 -244
  41. data/lib/impala/protocol/impala_internal_service_constants.rb +0 -12
  42. data/lib/impala/protocol/impala_internal_service_types.rb +0 -362
  43. data/lib/impala/protocol/impala_plan_service.rb +0 -310
  44. data/lib/impala/protocol/impala_plan_service_constants.rb +0 -12
  45. data/lib/impala/protocol/impala_plan_service_types.rb +0 -36
  46. data/lib/impala/protocol/java_constants_constants.rb +0 -42
  47. data/lib/impala/protocol/java_constants_types.rb +0 -14
  48. data/lib/impala/protocol/opcodes_constants.rb +0 -12
  49. data/lib/impala/protocol/opcodes_types.rb +0 -309
  50. data/lib/impala/protocol/partitions_constants.rb +0 -12
  51. data/lib/impala/protocol/partitions_types.rb +0 -44
  52. data/lib/impala/protocol/plan_nodes_constants.rb +0 -12
  53. data/lib/impala/protocol/plan_nodes_types.rb +0 -345
  54. data/lib/impala/protocol/planner_constants.rb +0 -12
  55. data/lib/impala/protocol/planner_types.rb +0 -78
  56. data/lib/impala/protocol/runtime_profile_constants.rb +0 -12
  57. data/lib/impala/protocol/runtime_profile_types.rb +0 -97
  58. data/lib/impala/protocol/state_store_service.rb +0 -244
  59. data/lib/impala/protocol/state_store_service_constants.rb +0 -12
  60. data/lib/impala/protocol/state_store_service_types.rb +0 -185
  61. data/lib/impala/protocol/state_store_subscriber_service.rb +0 -82
  62. data/lib/impala/protocol/state_store_subscriber_service_constants.rb +0 -12
  63. data/lib/impala/protocol/state_store_subscriber_service_types.rb +0 -67
  64. data/lib/impala/protocol/statestore_types_constants.rb +0 -12
  65. data/lib/impala/protocol/statestore_types_types.rb +0 -77
  66. data/lib/impala/protocol/types_constants.rb +0 -12
  67. data/lib/impala/protocol/types_types.rb +0 -86
  68. data/thrift/Data.thrift +0 -52
  69. data/thrift/DataSinks.thrift +0 -61
  70. data/thrift/Descriptors.thrift +0 -115
  71. data/thrift/Exprs.thrift +0 -134
  72. data/thrift/Frontend.thrift +0 -193
  73. data/thrift/ImpalaInternalService.thrift +0 -265
  74. data/thrift/ImpalaPlanService.thrift +0 -44
  75. data/thrift/JavaConstants.thrift +0 -60
  76. data/thrift/Opcodes.thrift +0 -317
  77. data/thrift/Partitions.thrift +0 -41
  78. data/thrift/PlanNodes.thrift +0 -184
  79. data/thrift/Planner.thrift +0 -72
  80. data/thrift/RuntimeProfile.thrift +0 -58
  81. data/thrift/StateStoreService.thrift +0 -121
  82. data/thrift/StateStoreSubscriberService.thrift +0 -64
  83. data/thrift/StatestoreTypes.thrift +0 -50
  84. data/thrift/Types.thrift +0 -71
@@ -1,3 +1,3 @@
1
1
  module Impala
2
- VERSION = "0.1.6"
2
+ VERSION = "0.2.0"
3
3
  end
@@ -16,17 +16,21 @@ def connect
16
16
  Impala.connect(host, port)
17
17
  end
18
18
 
19
- describe 'connected tests' do
19
+ describe 'basic connected tests' do
20
20
  before do
21
21
  skip unless IMPALA_SERVER
22
22
  @connection = connect
23
23
  end
24
24
 
25
- it 'can successfully connect' do
25
+ it 'can connect' do
26
26
  assert_instance_of(Impala::Connection, @connection)
27
27
  assert(@connection.open?, "the connection should be open")
28
28
  end
29
29
 
30
+ it 'can refresh the catalog' do
31
+ @connection.refresh
32
+ end
33
+
30
34
  it 'can run a basic query' do
31
35
  ret = @connection.query('SELECT "foo" AS foo')
32
36
  assert_equal([{:foo=>'foo'}], ret, "the result should be a list of hashes")
@@ -55,21 +59,97 @@ describe 'connected tests' do
55
59
  it 'can successfully refresh the metadata store' do
56
60
  ret = @connection.refresh
57
61
  end
62
+ end
58
63
 
59
- # TODO: this test sucks because there's no way to get multiple records
60
- # with a literal select. perhaps there should be importable test data?
61
- it 'can get a cursor and fetch one row at a time' do
62
- cursor = @connection.execute('SELECT 1 AS a')
63
- assert_instance_of(Impala::Cursor, cursor, "the result should be a cursor")
64
+ describe 'with a test database' do
65
+ before do
66
+ @database = '_impala_ruby_test'
67
+ @connection.query("CREATE DATABASE IF NOT EXISTS #{@database}")
68
+ end
64
69
 
65
- row = cursor.fetch_row
66
- assert_equal({:a=>1}, row, "the row should be a hash")
70
+ after do
71
+ @connection.query('DROP DATABASE IF EXISTS _impala_ruby_test')
72
+ end
67
73
 
68
- assert_equal(false, cursor.has_more?, "has_more? should be false")
69
- assert_nil(cursor.fetch_row, "subsequent calls to fetch_row should be nil")
74
+ it 'can use the database' do
75
+ @connection.query("USE #{@database}")
76
+ @connection.query("USE default")
70
77
  end
71
78
 
72
- it 'can successfully run a "use" query' do
73
- @connection.query('USE foo')
79
+ describe 'and a test table' do
80
+ before do
81
+ @table = "#{@database}.foobar"
82
+ @connection.query("CREATE TABLE #{@table} (i INT)")
83
+ end
84
+
85
+ after do
86
+ @connection.query("DROP TABLE #{@table}")
87
+ end
88
+
89
+ it 'deals with empty tables correctly when using #query' do
90
+ res = @connection.query("SELECT * FROM #{@table}")
91
+ assert_equal([], res, "the result set should be empty")
92
+ end
93
+
94
+ it 'deals with empty tables correctly when using a cursor' do
95
+ cursor = @connection.execute("SELECT * FROM #{@table}")
96
+ assert_equal(false, cursor.has_more?, "has_more? should be false")
97
+ assert_nil(cursor.fetch_row, "calls to fetch_row should be nil")
98
+ end
99
+
100
+ describe 'with data' do
101
+ before do
102
+ @connection.query("INSERT INTO #{@table} (i) SELECT 1")
103
+ @connection.query("INSERT INTO #{@table} (i) SELECT 1")
104
+ @connection.query("INSERT INTO #{@table} (i) SELECT 1")
105
+ end
106
+
107
+ it 'can insert into the table' do
108
+ @connection.query("INSERT INTO #{@table} (i) SELECT 2")
109
+ end
110
+
111
+ it 'can select from the table using #query' do
112
+ res = @connection.query("SELECT * FROM #{@table}")
113
+ assert_equal([{:i => 1}, {:i => 1}, {:i => 1}], res)
114
+ end
115
+
116
+ it 'can create a cursor and fetch one row at a time' do
117
+ cursor = @connection.execute("SELECT * FROM #{@table}")
118
+ assert_instance_of(Impala::Cursor, cursor, "the result should be a cursor")
119
+
120
+ 3.times do
121
+ row = cursor.fetch_row
122
+ assert_equal({:i=>1}, row, "the row should be a hash with the correct result")
123
+ end
124
+
125
+ assert_equal(false, cursor.has_more?, "has_more? should be false")
126
+ assert_nil(cursor.fetch_row, "subsequent calls to fetch_row should be nil")
127
+ end
128
+
129
+ it 'can use a cursor to deal with lots of data' do
130
+ 10.times { @connection.query("INSERT INTO #{@table} SELECT * FROM #{@table}") }
131
+ @connection.query("INSERT INTO #{@table} (i) SELECT 1")
132
+ count = @connection.query("SELECT COUNT(*) as n from #{@table}")[0][:n]
133
+ assert(count > Impala::Cursor::BUFFER_SIZE) # otherwise the test is pointless
134
+
135
+ cursor = @connection.execute("SELECT * FROM #{@table}")
136
+ assert_instance_of(Impala::Cursor, cursor, "the result should be a cursor")
137
+
138
+ # fetch one to fill the buffer
139
+ row = cursor.fetch_row
140
+ assert_equal({:i=>1}, row, "the row should be a hash with the correct result")
141
+
142
+ buffer_size = cursor.instance_variable_get('@row_buffer').size
143
+ assert_equal(Impala::Cursor::BUFFER_SIZE - 1, buffer_size, "it should only buffer #{Impala::Cursor::BUFFER_SIZE} rows into memory")
144
+
145
+ (count - 1).times do
146
+ row = cursor.fetch_row
147
+ assert_equal({:i=>1}, row, "the row should be a hash with the correct result")
148
+ end
149
+
150
+ assert_equal(false, cursor.has_more?, "has_more? should be false")
151
+ assert_nil(cursor.fetch_row, "subsequent calls to fetch_row should be nil")
152
+ end
153
+ end
74
154
  end
75
155
  end
@@ -14,21 +14,21 @@
14
14
 
15
15
  namespace cpp impala
16
16
  namespace java com.cloudera.impala.thrift
17
- namespace rb Impala.Protocol
17
+ namespace rb impala.protocol
18
18
 
19
19
  include "Status.thrift"
20
20
  include "beeswax.thrift"
21
+ include "cli_service.thrift"
21
22
 
22
23
  // ImpalaService accepts query execution options through beeswax.Query.configuration in
23
24
  // key:value form. For example, the list of strings could be:
24
25
  // "num_nodes:1", "abort_on_error:false"
25
26
  // The valid keys are listed in this enum. They map to TQueryOptions.
26
27
  // Note: If you add an option or change the default, you also need to update:
27
- // - JavaConstants.DEFAULT_QUERY_OPTIONS
28
28
  // - ImpalaInternalService.thrift: TQueryOptions
29
29
  // - ImpaladClientExecutor.getBeeswaxQueryConfigurations()
30
- // - ImpalaServer::QueryToTClientRequest()
31
- // - ImpalaServer::InitializeConfigVariables()
30
+ // - ImpalaServer::SetQueryOptions()
31
+ // - ImpalaServer::TQueryOptionsToMap()
32
32
  enum TImpalaQueryOptions {
33
33
  // if true, abort execution on the first error
34
34
  ABORT_ON_ERROR,
@@ -43,6 +43,13 @@ enum TImpalaQueryOptions {
43
43
  // default
44
44
  BATCH_SIZE,
45
45
 
46
+ // a per-machine approximate limit on the memory consumption of this query;
47
+ // unspecified or a limit of 0 means no limit;
48
+ // otherwise specified either as:
49
+ // a) an int (= number of bytes);
50
+ // b) a float followed by "M" (MB) or "G" (GB)
51
+ MEM_LIMIT,
52
+
46
53
  // specifies the degree of parallelism with which to execute the query;
47
54
  // 1: single-node execution
48
55
  // NUM_NODES_ALL: executes on all nodes that contain relevant data
@@ -70,6 +77,41 @@ enum TImpalaQueryOptions {
70
77
  // with an ORDER BY but without a LIMIT clause (ie, if the SELECT statement also has
71
78
  // a LIMIT clause, this default is ignored)
72
79
  DEFAULT_ORDER_BY_LIMIT,
80
+
81
+ // DEBUG ONLY:
82
+ // If set to
83
+ // "[<backend number>:]<node id>:<TExecNodePhase>:<TDebugAction>",
84
+ // the exec node with the given id will perform the specified action in the given
85
+ // phase. If the optional backend number (starting from 0) is specified, only that
86
+ // backend instance will perform the debug action, otherwise all backends will behave
87
+ // in that way.
88
+ // If the string doesn't have the required format or if any of its components is
89
+ // invalid, the option is ignored.
90
+ DEBUG_ACTION,
91
+
92
+ // If true, raise an error when the DEFAULT_ORDER_BY_LIMIT has been reached.
93
+ ABORT_ON_DEFAULT_LIMIT_EXCEEDED,
94
+
95
+ // Compression codec for parquet when inserting into parquet tables.
96
+ // Valid values are "snappy", "gzip" and "none"
97
+ // Leave blank to use default.
98
+ PARQUET_COMPRESSION_CODEC,
99
+
100
+ // HBase scan query option. If set and > 0, HBASE_CACHING is the value for
101
+ // "hbase.client.Scan.setCaching()" when querying HBase table. Otherwise, use backend
102
+ // default.
103
+ // If the value is too high, then the hbase region server will have a hard time (GC
104
+ // pressure and long response times). If the value is too small, then there will be
105
+ // extra trips to the hbase region server.
106
+ HBASE_CACHING,
107
+
108
+ // HBase scan query option. If set, HBase scan will always set
109
+ // "hbase.client.setCacheBlocks" to CACHE_BLOCKS. Default is false.
110
+ // If the table is large and the query is doing big scan, set it to false to
111
+ // avoid polluting the cache in the hbase region server.
112
+ // If the table is small and the table is used several time, set it to true to improve
113
+ // performance.
114
+ HBASE_CACHE_BLOCKS,
73
115
  }
74
116
 
75
117
  // The summary of an insert.
@@ -80,6 +122,22 @@ struct TInsertResult {
80
122
  1: required map<string, i64> rows_appended
81
123
  }
82
124
 
125
+ // Response from a call to PingImpalaService
126
+ struct TPingImpalaServiceResp {
127
+ // The Impala service's version string.
128
+ 1: string version
129
+ }
130
+
131
+ // Parameters for a ResetTable request which will invalidate a table's metadata.
132
+ // DEPRECATED.
133
+ struct TResetTableReq {
134
+ // Name of the table's parent database.
135
+ 1: required string db_name
136
+
137
+ // Name of the table.
138
+ 2: required string table_name
139
+ }
140
+
83
141
  // For all rpc that return a TStatus as part of their result type,
84
142
  // if the status_code field is set to anything other than OK, the contents
85
143
  // of the remainder of the result type is undefined (typically not set)
@@ -94,12 +152,26 @@ service ImpalaService extends beeswax.BeeswaxService {
94
152
  throws(1:beeswax.BeeswaxException error);
95
153
 
96
154
  // Invalidates all catalog metadata, forcing a reload
155
+ // DEPRECATED; execute query "invalidate metadata" to refresh metadata
97
156
  Status.TStatus ResetCatalog();
98
157
 
158
+ // Invalidates a specific table's catalog metadata, forcing a reload on the next access
159
+ // DEPRECATED; execute query "refresh <table>" to refresh metadata
160
+ Status.TStatus ResetTable(1:TResetTableReq request)
161
+
162
+ // Returns the runtime profile string for the given query handle.
163
+ string GetRuntimeProfile(1:beeswax.QueryHandle query_id)
164
+ throws(1:beeswax.BeeswaxException error);
165
+
99
166
  // Closes the query handle and return the result summary of the insert.
100
167
  TInsertResult CloseInsert(1:beeswax.QueryHandle handle)
101
168
  throws(1:beeswax.QueryNotFoundException error, 2:beeswax.BeeswaxException error2);
102
169
 
103
- // Client calls this RPC to verify that the server is an ImpalaService.
104
- void PingImpalaService();
170
+ // Client calls this RPC to verify that the server is an ImpalaService. Returns the
171
+ // server version.
172
+ TPingImpalaServiceResp PingImpalaService();
173
+ }
174
+
175
+ // Impala HiveServer2 service
176
+ service ImpalaHiveServer2Service extends cli_service.TCLIService {
105
177
  }
@@ -14,7 +14,7 @@
14
14
 
15
15
  namespace cpp impala
16
16
  namespace java com.cloudera.impala.thrift
17
- namespace rb Impala.Protocol
17
+ namespace rb impala.protocol
18
18
 
19
19
  enum TStatusCode {
20
20
  OK,
@@ -22,6 +22,7 @@ enum TStatusCode {
22
22
  ANALYSIS_ERROR,
23
23
  NOT_IMPLEMENTED_ERROR,
24
24
  RUNTIME_ERROR,
25
+ MEM_LIMIT_EXCEEDED,
25
26
  INTERNAL_ERROR
26
27
  }
27
28
 
@@ -21,7 +21,7 @@
21
21
  namespace java com.cloudera.beeswax.api
22
22
  namespace py beeswaxd
23
23
  namespace cpp beeswax
24
- namespace rb Impala.Protocol.Beeswax
24
+ namespace rb impala.protocol.beeswax
25
25
 
26
26
  include "hive_metastore.thrift"
27
27
 
@@ -0,0 +1,1015 @@
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
+
17
+ // Coding Conventions for this file:
18
+ //
19
+ // Structs/Enums/Unions
20
+ // * Struct, Enum, and Union names begin with a "T",
21
+ // and use a capital letter for each new word, with no underscores.
22
+ // * All fields should be declared as either optional or required.
23
+ //
24
+ // Functions
25
+ // * Function names start with a capital letter and have a capital letter for
26
+ // each new word, with no underscores.
27
+ // * Each function should take exactly one parameter, named TFunctionNameReq,
28
+ // and should return either void or TFunctionNameResp. This convention allows
29
+ // incremental updates.
30
+ //
31
+ // Services
32
+ // * Service names begin with the letter "T", use a capital letter for each
33
+ // new word (with no underscores), and end with the word "Service".
34
+
35
+ namespace java org.apache.hive.service.cli.thrift
36
+ namespace cpp apache.hive.service.cli.thrift
37
+ namespace rb impala.protocol.hive
38
+
39
+ // List of protocol versions. A new token should be
40
+ // added to the end of this list every time a change is made.
41
+ enum TProtocolVersion {
42
+ HIVE_CLI_SERVICE_PROTOCOL_V1
43
+ }
44
+
45
+ enum TTypeId {
46
+ BOOLEAN_TYPE,
47
+ TINYINT_TYPE,
48
+ SMALLINT_TYPE,
49
+ INT_TYPE,
50
+ BIGINT_TYPE,
51
+ FLOAT_TYPE,
52
+ DOUBLE_TYPE,
53
+ STRING_TYPE,
54
+ TIMESTAMP_TYPE,
55
+ BINARY_TYPE,
56
+ ARRAY_TYPE,
57
+ MAP_TYPE,
58
+ STRUCT_TYPE,
59
+ UNION_TYPE,
60
+ USER_DEFINED_TYPE,
61
+ DECIMAL_TYPE
62
+ }
63
+
64
+ const set<TTypeId> PRIMITIVE_TYPES = [
65
+ TTypeId.BOOLEAN_TYPE
66
+ TTypeId.TINYINT_TYPE
67
+ TTypeId.SMALLINT_TYPE
68
+ TTypeId.INT_TYPE
69
+ TTypeId.BIGINT_TYPE
70
+ TTypeId.FLOAT_TYPE
71
+ TTypeId.DOUBLE_TYPE
72
+ TTypeId.STRING_TYPE
73
+ TTypeId.TIMESTAMP_TYPE
74
+ TTypeId.BINARY_TYPE,
75
+ TTypeId.DECIMAL_TYPE
76
+ ]
77
+
78
+ const set<TTypeId> COMPLEX_TYPES = [
79
+ TTypeId.ARRAY_TYPE
80
+ TTypeId.MAP_TYPE
81
+ TTypeId.STRUCT_TYPE
82
+ TTypeId.UNION_TYPE
83
+ TTypeId.USER_DEFINED_TYPE
84
+ ]
85
+
86
+ const set<TTypeId> COLLECTION_TYPES = [
87
+ TTypeId.ARRAY_TYPE
88
+ TTypeId.MAP_TYPE
89
+ ]
90
+
91
+ const map<TTypeId,string> TYPE_NAMES = {
92
+ TTypeId.BOOLEAN_TYPE: "BOOLEAN",
93
+ TTypeId.TINYINT_TYPE: "TINYINT",
94
+ TTypeId.SMALLINT_TYPE: "SMALLINT",
95
+ TTypeId.INT_TYPE: "INT",
96
+ TTypeId.BIGINT_TYPE: "BIGINT",
97
+ TTypeId.FLOAT_TYPE: "FLOAT",
98
+ TTypeId.DOUBLE_TYPE: "DOUBLE",
99
+ TTypeId.STRING_TYPE: "STRING",
100
+ TTypeId.TIMESTAMP_TYPE: "TIMESTAMP",
101
+ TTypeId.BINARY_TYPE: "BINARY",
102
+ TTypeId.ARRAY_TYPE: "ARRAY",
103
+ TTypeId.MAP_TYPE: "MAP",
104
+ TTypeId.STRUCT_TYPE: "STRUCT",
105
+ TTypeId.UNION_TYPE: "UNIONTYPE"
106
+ TTypeId.DECIMAL_TYPE: "DECIMAL"
107
+ }
108
+
109
+ // Thrift does not support recursively defined types or forward declarations,
110
+ // which makes it difficult to represent Hive's nested types.
111
+ // To get around these limitations TTypeDesc employs a type list that maps
112
+ // integer "pointers" to TTypeEntry objects. The following examples show
113
+ // how different types are represented using this scheme:
114
+ //
115
+ // "INT":
116
+ // TTypeDesc {
117
+ // types = [
118
+ // TTypeEntry.primitive_entry {
119
+ // type = INT_TYPE
120
+ // }
121
+ // ]
122
+ // }
123
+ //
124
+ // "ARRAY<INT>":
125
+ // TTypeDesc {
126
+ // types = [
127
+ // TTypeEntry.array_entry {
128
+ // object_type_ptr = 1
129
+ // },
130
+ // TTypeEntry.primitive_entry {
131
+ // type = INT_TYPE
132
+ // }
133
+ // ]
134
+ // }
135
+ //
136
+ // "MAP<INT,STRING>":
137
+ // TTypeDesc {
138
+ // types = [
139
+ // TTypeEntry.map_entry {
140
+ // key_type_ptr = 1
141
+ // value_type_ptr = 2
142
+ // },
143
+ // TTypeEntry.primitive_entry {
144
+ // type = INT_TYPE
145
+ // },
146
+ // TTypeEntry.primitive_entry {
147
+ // type = STRING_TYPE
148
+ // }
149
+ // ]
150
+ // }
151
+
152
+ typedef i32 TTypeEntryPtr
153
+
154
+ // Type entry for a primitive type.
155
+ struct TPrimitiveTypeEntry {
156
+ // The primitive type token. This must satisfy the condition
157
+ // that type is in the PRIMITIVE_TYPES set.
158
+ 1: required TTypeId type
159
+ }
160
+
161
+ // Type entry for an ARRAY type.
162
+ struct TArrayTypeEntry {
163
+ 1: required TTypeEntryPtr objectTypePtr
164
+ }
165
+
166
+ // Type entry for a MAP type.
167
+ struct TMapTypeEntry {
168
+ 1: required TTypeEntryPtr keyTypePtr
169
+ 2: required TTypeEntryPtr valueTypePtr
170
+ }
171
+
172
+ // Type entry for a STRUCT type.
173
+ struct TStructTypeEntry {
174
+ 1: required map<string, TTypeEntryPtr> nameToTypePtr
175
+ }
176
+
177
+ // Type entry for a UNIONTYPE type.
178
+ struct TUnionTypeEntry {
179
+ 1: required map<string, TTypeEntryPtr> nameToTypePtr
180
+ }
181
+
182
+ struct TUserDefinedTypeEntry {
183
+ // The fully qualified name of the class implementing this type.
184
+ 1: required string typeClassName
185
+ }
186
+
187
+ // We use a union here since Thrift does not support inheritance.
188
+ union TTypeEntry {
189
+ 1: TPrimitiveTypeEntry primitiveEntry
190
+ 2: TArrayTypeEntry arrayEntry
191
+ 3: TMapTypeEntry mapEntry
192
+ 4: TStructTypeEntry structEntry
193
+ 5: TUnionTypeEntry unionEntry
194
+ 6: TUserDefinedTypeEntry userDefinedTypeEntry
195
+ }
196
+
197
+ // Type descriptor for columns.
198
+ struct TTypeDesc {
199
+ // The "top" type is always the first element of the list.
200
+ // If the top type is an ARRAY, MAP, STRUCT, or UNIONTYPE
201
+ // type, then subsequent elements represent nested types.
202
+ 1: required list<TTypeEntry> types
203
+ }
204
+
205
+ // A result set column descriptor.
206
+ struct TColumnDesc {
207
+ // The name of the column
208
+ 1: required string columnName
209
+
210
+ // The type descriptor for this column
211
+ 2: required TTypeDesc typeDesc
212
+
213
+ // The ordinal position of this column in the schema
214
+ 3: required i32 position
215
+
216
+ 4: optional string comment
217
+ }
218
+
219
+ // Metadata used to describe the schema (column names, types, comments)
220
+ // of result sets.
221
+ struct TTableSchema {
222
+ 1: required list<TColumnDesc> columns
223
+ }
224
+
225
+ // A Boolean column value.
226
+ struct TBoolValue {
227
+ // NULL if value is unset.
228
+ 1: optional bool value
229
+ }
230
+
231
+ // A Byte column value.
232
+ struct TByteValue {
233
+ // NULL if value is unset.
234
+ 1: optional byte value
235
+ }
236
+
237
+ // A signed, 16 bit column value.
238
+ struct TI16Value {
239
+ // NULL if value is unset
240
+ 1: optional i16 value
241
+ }
242
+
243
+ // A signed, 32 bit column value
244
+ struct TI32Value {
245
+ // NULL if value is unset
246
+ 1: optional i32 value
247
+ }
248
+
249
+ // A signed 64 bit column value
250
+ struct TI64Value {
251
+ // NULL if value is unset
252
+ 1: optional i64 value
253
+ }
254
+
255
+ // A floating point 64 bit column value
256
+ struct TDoubleValue {
257
+ // NULL if value is unset
258
+ 1: optional double value
259
+ }
260
+
261
+ struct TStringValue {
262
+ // NULL if value is unset
263
+ 1: optional string value
264
+ }
265
+
266
+ union TColumn {
267
+ 1: list<TBoolValue> boolColumn
268
+ 2: list<TByteValue> byteColumn
269
+ 3: list<TI16Value> i16Column
270
+ 4: list<TI32Value> i32Column
271
+ 5: list<TI64Value> i64Column
272
+ 6: list<TDoubleValue> doubleColumn
273
+ 7: list<TStringValue> stringColumn
274
+ }
275
+
276
+ // A single column value in a result set.
277
+ // Note that Hive's type system is richer than Thrift's,
278
+ // so in some cases we have to map multiple Hive types
279
+ // to the same Thrift type. On the client-side this is
280
+ // disambiguated by looking at the Schema of the
281
+ // result set.
282
+ union TColumnValue {
283
+ 1: TBoolValue boolVal // BOOLEAN
284
+ 2: TByteValue byteVal // TINYINT
285
+ 3: TI16Value i16Val // SMALLINT
286
+ 4: TI32Value i32Val // INT
287
+ 5: TI64Value i64Val // BIGINT, TIMESTAMP
288
+ 6: TDoubleValue doubleVal // FLOAT, DOUBLE
289
+ 7: TStringValue stringVal // STRING, LIST, MAP, STRUCT, UNIONTYPE, BINARY, DECIMAL
290
+ }
291
+
292
+ // Represents a row in a rowset.
293
+ struct TRow {
294
+ 1: required list<TColumnValue> colVals
295
+ }
296
+
297
+ // Represents a rowset
298
+ struct TRowSet {
299
+ // The starting row offset of this rowset.
300
+ 1: required i64 startRowOffset
301
+ 2: required list<TRow> rows
302
+ 3: optional list<TColumn> columns
303
+ }
304
+
305
+ // The return status code contained in each response.
306
+ enum TStatusCode {
307
+ SUCCESS_STATUS,
308
+ SUCCESS_WITH_INFO_STATUS,
309
+ STILL_EXECUTING_STATUS,
310
+ ERROR_STATUS,
311
+ INVALID_HANDLE_STATUS
312
+ }
313
+
314
+ // The return status of a remote request
315
+ struct TStatus {
316
+ 1: required TStatusCode statusCode
317
+
318
+ // If status is SUCCESS_WITH_INFO, info_msgs may be populated with
319
+ // additional diagnostic information.
320
+ 2: optional list<string> infoMessages
321
+
322
+ // If status is ERROR, then the following fields may be set
323
+ 3: optional string sqlState // as defined in the ISO/IEF CLI specification
324
+ 4: optional i32 errorCode // internal error code
325
+ 5: optional string errorMessage
326
+ }
327
+
328
+ // The state of an operation (i.e. a query or other
329
+ // asynchronous operation that generates a result set)
330
+ // on the server.
331
+ enum TOperationState {
332
+ // The operation has been initialized
333
+ INITIALIZED_STATE,
334
+
335
+ // The operation is running. In this state the result
336
+ // set is not available.
337
+ RUNNING_STATE,
338
+
339
+ // The operation has completed. When an operation is in
340
+ // this state its result set may be fetched.
341
+ FINISHED_STATE,
342
+
343
+ // The operation was canceled by a client
344
+ CANCELED_STATE,
345
+
346
+ // The operation was closed by a client
347
+ CLOSED_STATE,
348
+
349
+ // The operation failed due to an error
350
+ ERROR_STATE,
351
+
352
+ // The operation is in an unrecognized state
353
+ UKNOWN_STATE,
354
+ }
355
+
356
+
357
+ // A string identifier. This is interpreted literally.
358
+ typedef string TIdentifier
359
+
360
+ // A search pattern.
361
+ //
362
+ // Valid search pattern characters:
363
+ // '_': Any single character.
364
+ // '%': Any sequence of zero or more characters.
365
+ // '\': Escape character used to include special characters,
366
+ // e.g. '_', '%', '\'. If a '\' precedes a non-special
367
+ // character it has no special meaning and is interpreted
368
+ // literally.
369
+ typedef string TPattern
370
+
371
+
372
+ // A search pattern or identifier. Used as input
373
+ // parameter for many of the catalog functions.
374
+ typedef string TPatternOrIdentifier
375
+
376
+ struct THandleIdentifier {
377
+ // 16 byte globally unique identifier
378
+ // This is the public ID of the handle and
379
+ // can be used for reporting.
380
+ 1: required binary guid,
381
+
382
+ // 16 byte secret generated by the server
383
+ // and used to verify that the handle is not
384
+ // being hijacked by another user.
385
+ 2: required binary secret,
386
+ }
387
+
388
+ // Client-side handle to persistent
389
+ // session information on the server-side.
390
+ struct TSessionHandle {
391
+ 1: required THandleIdentifier sessionId
392
+ }
393
+
394
+ // The subtype of an OperationHandle.
395
+ enum TOperationType {
396
+ EXECUTE_STATEMENT,
397
+ GET_TYPE_INFO,
398
+ GET_CATALOGS,
399
+ GET_SCHEMAS,
400
+ GET_TABLES,
401
+ GET_TABLE_TYPES,
402
+ GET_COLUMNS,
403
+ GET_FUNCTIONS,
404
+ UNKNOWN,
405
+ }
406
+
407
+ // Client-side reference to a task running
408
+ // asynchronously on the server.
409
+ struct TOperationHandle {
410
+ 1: required THandleIdentifier operationId
411
+ 2: required TOperationType operationType
412
+
413
+ // If hasResultSet = TRUE, then this operation
414
+ // generates a result set that can be fetched.
415
+ // Note that the result set may be empty.
416
+ //
417
+ // If hasResultSet = FALSE, then this operation
418
+ // does not generate a result set, and calling
419
+ // GetResultSetMetadata or FetchResults against
420
+ // this OperationHandle will generate an error.
421
+ 3: required bool hasResultSet
422
+
423
+ // For operations that don't generate result sets,
424
+ // modifiedRowCount is either:
425
+ //
426
+ // 1) The number of rows that were modified by
427
+ // the DML operation (e.g. number of rows inserted,
428
+ // number of rows deleted, etc).
429
+ //
430
+ // 2) 0 for operations that don't modify or add rows.
431
+ //
432
+ // 3) < 0 if the operation is capable of modifiying rows,
433
+ // but Hive is unable to determine how many rows were
434
+ // modified. For example, Hive's LOAD DATA command
435
+ // doesn't generate row count information because
436
+ // Hive doesn't inspect the data as it is loaded.
437
+ //
438
+ // modifiedRowCount is unset if the operation generates
439
+ // a result set.
440
+ 4: optional double modifiedRowCount
441
+ }
442
+
443
+
444
+ // OpenSession()
445
+ //
446
+ // Open a session (connection) on the server against
447
+ // which operations may be executed.
448
+ struct TOpenSessionReq {
449
+ // The version of the HiveServer2 protocol that the client is using.
450
+ 1: required TProtocolVersion client_protocol = TProtocolVersion.HIVE_CLI_SERVICE_PROTOCOL_V1
451
+
452
+ // Username and password for authentication.
453
+ // Depending on the authentication scheme being used,
454
+ // this information may instead be provided by a lower
455
+ // protocol layer, in which case these fields may be
456
+ // left unset.
457
+ 2: optional string username
458
+ 3: optional string password
459
+
460
+ // Configuration overlay which is applied when the session is
461
+ // first created.
462
+ 4: optional map<string, string> configuration
463
+ }
464
+
465
+ struct TOpenSessionResp {
466
+ 1: required TStatus status
467
+
468
+ // The protocol version that the server is using.
469
+ 2: required TProtocolVersion serverProtocolVersion = TProtocolVersion.HIVE_CLI_SERVICE_PROTOCOL_V1
470
+
471
+ // Session Handle
472
+ 3: optional TSessionHandle sessionHandle
473
+
474
+ // The configuration settings for this session.
475
+ 4: optional map<string, string> configuration
476
+ }
477
+
478
+
479
+ // CloseSession()
480
+ //
481
+ // Closes the specified session and frees any resources
482
+ // currently allocated to that session. Any open
483
+ // operations in that session will be canceled.
484
+ struct TCloseSessionReq {
485
+ 1: required TSessionHandle sessionHandle
486
+ }
487
+
488
+ struct TCloseSessionResp {
489
+ 1: required TStatus status
490
+ }
491
+
492
+
493
+
494
+ enum TGetInfoType {
495
+ CLI_MAX_DRIVER_CONNECTIONS = 0,
496
+ CLI_MAX_CONCURRENT_ACTIVITIES = 1,
497
+ CLI_DATA_SOURCE_NAME = 2,
498
+ CLI_FETCH_DIRECTION = 8,
499
+ CLI_SERVER_NAME = 13,
500
+ CLI_SEARCH_PATTERN_ESCAPE = 14,
501
+ CLI_DBMS_NAME = 17,
502
+ CLI_DBMS_VER = 18,
503
+ CLI_ACCESSIBLE_TABLES = 19,
504
+ CLI_ACCESSIBLE_PROCEDURES = 20,
505
+ CLI_CURSOR_COMMIT_BEHAVIOR = 23,
506
+ CLI_DATA_SOURCE_READ_ONLY = 25,
507
+ CLI_DEFAULT_TXN_ISOLATION = 26,
508
+ CLI_IDENTIFIER_CASE = 28,
509
+ CLI_IDENTIFIER_QUOTE_CHAR = 29,
510
+ CLI_MAX_COLUMN_NAME_LEN = 30,
511
+ CLI_MAX_CURSOR_NAME_LEN = 31,
512
+ CLI_MAX_SCHEMA_NAME_LEN = 32,
513
+ CLI_MAX_CATALOG_NAME_LEN = 34,
514
+ CLI_MAX_TABLE_NAME_LEN = 35,
515
+ CLI_SCROLL_CONCURRENCY = 43,
516
+ CLI_TXN_CAPABLE = 46,
517
+ CLI_USER_NAME = 47,
518
+ CLI_TXN_ISOLATION_OPTION = 72,
519
+ CLI_INTEGRITY = 73,
520
+ CLI_GETDATA_EXTENSIONS = 81,
521
+ CLI_NULL_COLLATION = 85,
522
+ CLI_ALTER_TABLE = 86,
523
+ CLI_ORDER_BY_COLUMNS_IN_SELECT = 90,
524
+ CLI_SPECIAL_CHARACTERS = 94,
525
+ CLI_MAX_COLUMNS_IN_GROUP_BY = 97,
526
+ CLI_MAX_COLUMNS_IN_INDEX = 98,
527
+ CLI_MAX_COLUMNS_IN_ORDER_BY = 99,
528
+ CLI_MAX_COLUMNS_IN_SELECT = 100,
529
+ CLI_MAX_COLUMNS_IN_TABLE = 101,
530
+ CLI_MAX_INDEX_SIZE = 102,
531
+ CLI_MAX_ROW_SIZE = 104,
532
+ CLI_MAX_STATEMENT_LEN = 105,
533
+ CLI_MAX_TABLES_IN_SELECT = 106,
534
+ CLI_MAX_USER_NAME_LEN = 107,
535
+ CLI_OJ_CAPABILITIES = 115,
536
+
537
+ CLI_XOPEN_CLI_YEAR = 10000,
538
+ CLI_CURSOR_SENSITIVITY = 10001,
539
+ CLI_DESCRIBE_PARAMETER = 10002,
540
+ CLI_CATALOG_NAME = 10003,
541
+ CLI_COLLATION_SEQ = 10004,
542
+ CLI_MAX_IDENTIFIER_LEN = 10005,
543
+ }
544
+
545
+ union TGetInfoValue {
546
+ 1: string stringValue
547
+ 2: i16 smallIntValue
548
+ 3: i32 integerBitmask
549
+ 4: i32 integerFlag
550
+ 5: i32 binaryValue
551
+ 6: i64 lenValue
552
+ }
553
+
554
+ // GetInfo()
555
+ //
556
+ // This function is based on ODBC's CLIGetInfo() function.
557
+ // The function returns general information about the data source
558
+ // using the same keys as ODBC.
559
+ struct TGetInfoReq {
560
+ // The sesssion to run this request against
561
+ 1: required TSessionHandle sessionHandle
562
+
563
+ 2: required TGetInfoType infoType
564
+ }
565
+
566
+ struct TGetInfoResp {
567
+ 1: required TStatus status
568
+
569
+ 2: required TGetInfoValue infoValue
570
+ }
571
+
572
+
573
+ // ExecuteStatement()
574
+ //
575
+ // Execute a statement.
576
+ // The returned OperationHandle can be used to check on the
577
+ // status of the statement, and to fetch results once the
578
+ // statement has finished executing.
579
+ struct TExecuteStatementReq {
580
+ // The session to exexcute the statement against
581
+ 1: required TSessionHandle sessionHandle
582
+
583
+ // The statement to be executed (DML, DDL, SET, etc)
584
+ 2: required string statement
585
+
586
+ // Configuration properties that are overlayed on top of the
587
+ // the existing session configuration before this statement
588
+ // is executed. These properties apply to this statement
589
+ // only and will not affect the subsequent state of the Session.
590
+ 3: optional map<string, string> confOverlay
591
+ }
592
+
593
+ struct TExecuteStatementResp {
594
+ 1: required TStatus status
595
+ 2: optional TOperationHandle operationHandle
596
+ }
597
+
598
+
599
+ // GetTypeInfo()
600
+ //
601
+ // Get information about types supported by the HiveServer instance.
602
+ // The information is returned as a result set which can be fetched
603
+ // using the OperationHandle provided in the response.
604
+ //
605
+ // Refer to the documentation for ODBC's CLIGetTypeInfo function for
606
+ // the format of the result set.
607
+ struct TGetTypeInfoReq {
608
+ // The session to run this request against.
609
+ 1: required TSessionHandle sessionHandle
610
+ }
611
+
612
+ struct TGetTypeInfoResp {
613
+ 1: required TStatus status
614
+ 2: optional TOperationHandle operationHandle
615
+ }
616
+
617
+
618
+ // GetCatalogs()
619
+ //
620
+ // Returns the list of catalogs (databases)
621
+ // Results are ordered by TABLE_CATALOG
622
+ //
623
+ // Resultset columns :
624
+ // col1
625
+ // name: TABLE_CAT
626
+ // type: STRING
627
+ // desc: Catalog name. NULL if not applicable.
628
+ //
629
+ struct TGetCatalogsReq {
630
+ // Session to run this request against
631
+ 1: required TSessionHandle sessionHandle
632
+ }
633
+
634
+ struct TGetCatalogsResp {
635
+ 1: required TStatus status
636
+ 2: optional TOperationHandle operationHandle
637
+ }
638
+
639
+
640
+ // GetSchemas()
641
+ //
642
+ // Retrieves the schema names available in this database.
643
+ // The results are ordered by TABLE_CATALOG and TABLE_SCHEM.
644
+ // col1
645
+ // name: TABLE_SCHEM
646
+ // type: STRING
647
+ // desc: schema name
648
+ // col2
649
+ // name: TABLE_CATALOG
650
+ // type: STRING
651
+ // desc: catalog name
652
+ struct TGetSchemasReq {
653
+ // Session to run this request against
654
+ 1: required TSessionHandle sessionHandle
655
+
656
+ // Name of the catalog. Must not contain a search pattern.
657
+ 2: optional TIdentifier catalogName
658
+
659
+ // schema name or pattern
660
+ 3: optional TPatternOrIdentifier schemaName
661
+ }
662
+
663
+ struct TGetSchemasResp {
664
+ 1: required TStatus status
665
+ 2: optional TOperationHandle operationHandle
666
+ }
667
+
668
+
669
+ // GetTables()
670
+ //
671
+ // Returns a list of tables with catalog, schema, and table
672
+ // type information. The information is returned as a result
673
+ // set which can be fetched using the OperationHandle
674
+ // provided in the response.
675
+ // Results are ordered by TABLE_TYPE, TABLE_CAT, TABLE_SCHEM, and TABLE_NAME
676
+ //
677
+ // Result Set Columns:
678
+ //
679
+ // col1
680
+ // name: TABLE_CAT
681
+ // type: STRING
682
+ // desc: Catalog name. NULL if not applicable.
683
+ //
684
+ // col2
685
+ // name: TABLE_SCHEM
686
+ // type: STRING
687
+ // desc: Schema name.
688
+ //
689
+ // col3
690
+ // name: TABLE_NAME
691
+ // type: STRING
692
+ // desc: Table name.
693
+ //
694
+ // col4
695
+ // name: TABLE_TYPE
696
+ // type: STRING
697
+ // desc: The table type, e.g. "TABLE", "VIEW", etc.
698
+ //
699
+ // col5
700
+ // name: REMARKS
701
+ // type: STRING
702
+ // desc: Comments about the table
703
+ //
704
+ struct TGetTablesReq {
705
+ // Session to run this request against
706
+ 1: required TSessionHandle sessionHandle
707
+
708
+ // Name of the catalog or a search pattern.
709
+ 2: optional TPatternOrIdentifier catalogName
710
+
711
+ // Name of the schema or a search pattern.
712
+ 3: optional TPatternOrIdentifier schemaName
713
+
714
+ // Name of the table or a search pattern.
715
+ 4: optional TPatternOrIdentifier tableName
716
+
717
+ // List of table types to match
718
+ // e.g. "TABLE", "VIEW", "SYSTEM TABLE", "GLOBAL TEMPORARY",
719
+ // "LOCAL TEMPORARY", "ALIAS", "SYNONYM", etc.
720
+ 5: optional list<string> tableTypes
721
+ }
722
+
723
+ struct TGetTablesResp {
724
+ 1: required TStatus status
725
+ 2: optional TOperationHandle operationHandle
726
+ }
727
+
728
+
729
+ // GetTableTypes()
730
+ //
731
+ // Returns the table types available in this database.
732
+ // The results are ordered by table type.
733
+ //
734
+ // col1
735
+ // name: TABLE_TYPE
736
+ // type: STRING
737
+ // desc: Table type name.
738
+ struct TGetTableTypesReq {
739
+ // Session to run this request against
740
+ 1: required TSessionHandle sessionHandle
741
+ }
742
+
743
+ struct TGetTableTypesResp {
744
+ 1: required TStatus status
745
+ 2: optional TOperationHandle operationHandle
746
+ }
747
+
748
+
749
+ // GetColumns()
750
+ //
751
+ // Returns a list of columns in the specified tables.
752
+ // The information is returned as a result set which can be fetched
753
+ // using the OperationHandle provided in the response.
754
+ // Results are ordered by TABLE_CAT, TABLE_SCHEM, TABLE_NAME,
755
+ // and ORDINAL_POSITION.
756
+ //
757
+ // Result Set Columns are the same as those for the ODBC CLIColumns
758
+ // function.
759
+ //
760
+ struct TGetColumnsReq {
761
+ // Session to run this request against
762
+ 1: required TSessionHandle sessionHandle
763
+
764
+ // Name of the catalog. Must not contain a search pattern.
765
+ 2: optional TIdentifier catalogName
766
+
767
+ // Schema name or search pattern
768
+ 3: optional TPatternOrIdentifier schemaName
769
+
770
+ // Table name or search pattern
771
+ 4: optional TPatternOrIdentifier tableName
772
+
773
+ // Column name or search pattern
774
+ 5: optional TPatternOrIdentifier columnName
775
+ }
776
+
777
+ struct TGetColumnsResp {
778
+ 1: required TStatus status
779
+ 2: optional TOperationHandle operationHandle
780
+ }
781
+
782
+
783
+ // GetFunctions()
784
+ //
785
+ // Returns a list of functions supported by the data source. The
786
+ // behavior of this function matches
787
+ // java.sql.DatabaseMetaData.getFunctions() both in terms of
788
+ // inputs and outputs.
789
+ //
790
+ // Result Set Columns:
791
+ //
792
+ // col1
793
+ // name: FUNCTION_CAT
794
+ // type: STRING
795
+ // desc: Function catalog (may be null)
796
+ //
797
+ // col2
798
+ // name: FUNCTION_SCHEM
799
+ // type: STRING
800
+ // desc: Function schema (may be null)
801
+ //
802
+ // col3
803
+ // name: FUNCTION_NAME
804
+ // type: STRING
805
+ // desc: Function name. This is the name used to invoke the function.
806
+ //
807
+ // col4
808
+ // name: REMARKS
809
+ // type: STRING
810
+ // desc: Explanatory comment on the function.
811
+ //
812
+ // col5
813
+ // name: FUNCTION_TYPE
814
+ // type: SMALLINT
815
+ // desc: Kind of function. One of:
816
+ // * functionResultUnknown - Cannot determine if a return value or a table
817
+ // will be returned.
818
+ // * functionNoTable - Does not a return a table.
819
+ // * functionReturnsTable - Returns a table.
820
+ //
821
+ // col6
822
+ // name: SPECIFIC_NAME
823
+ // type: STRING
824
+ // desc: The name which uniquely identifies this function within its schema.
825
+ // In this case this is the fully qualified class name of the class
826
+ // that implements this function.
827
+ //
828
+ struct TGetFunctionsReq {
829
+ // Session to run this request against
830
+ 1: required TSessionHandle sessionHandle
831
+
832
+ // A catalog name; must match the catalog name as it is stored in the
833
+ // database; "" retrieves those without a catalog; null means
834
+ // that the catalog name should not be used to narrow the search.
835
+ 2: optional TIdentifier catalogName
836
+
837
+ // A schema name pattern; must match the schema name as it is stored
838
+ // in the database; "" retrieves those without a schema; null means
839
+ // that the schema name should not be used to narrow the search.
840
+ 3: optional TPatternOrIdentifier schemaName
841
+
842
+ // A function name pattern; must match the function name as it is stored
843
+ // in the database.
844
+ 4: required TPatternOrIdentifier functionName
845
+ }
846
+
847
+ struct TGetFunctionsResp {
848
+ 1: required TStatus status
849
+ 2: optional TOperationHandle operationHandle
850
+ }
851
+
852
+
853
+ // GetOperationStatus()
854
+ //
855
+ // Get the status of an operation running on the server.
856
+ struct TGetOperationStatusReq {
857
+ // Session to run this request against
858
+ 1: required TOperationHandle operationHandle
859
+ }
860
+
861
+ struct TGetOperationStatusResp {
862
+ 1: required TStatus status
863
+ 2: optional TOperationState operationState
864
+ }
865
+
866
+
867
+ // CancelOperation()
868
+ //
869
+ // Cancels processing on the specified operation handle and
870
+ // frees any resources which were allocated.
871
+ struct TCancelOperationReq {
872
+ // Operation to cancel
873
+ 1: required TOperationHandle operationHandle
874
+ }
875
+
876
+ struct TCancelOperationResp {
877
+ 1: required TStatus status
878
+ }
879
+
880
+
881
+ // CloseOperation()
882
+ //
883
+ // Given an operation in the FINISHED, CANCELED,
884
+ // or ERROR states, CloseOperation() will free
885
+ // all of the resources which were allocated on
886
+ // the server to service the operation.
887
+ struct TCloseOperationReq {
888
+ 1: required TOperationHandle operationHandle
889
+ }
890
+
891
+ struct TCloseOperationResp {
892
+ 1: required TStatus status
893
+ }
894
+
895
+
896
+ // GetResultSetMetadata()
897
+ //
898
+ // Retrieves schema information for the specified operation
899
+ struct TGetResultSetMetadataReq {
900
+ // Operation for which to fetch result set schema information
901
+ 1: required TOperationHandle operationHandle
902
+ }
903
+
904
+ struct TGetResultSetMetadataResp {
905
+ 1: required TStatus status
906
+ 2: optional TTableSchema schema
907
+ }
908
+
909
+
910
+ enum TFetchOrientation {
911
+ // Get the next rowset. The fetch offset is ignored.
912
+ FETCH_NEXT,
913
+
914
+ // Get the previous rowset. The fetch offset is ignored.
915
+ // NOT SUPPORTED
916
+ FETCH_PRIOR,
917
+
918
+ // Return the rowset at the given fetch offset relative
919
+ // to the curren rowset.
920
+ // NOT SUPPORTED
921
+ FETCH_RELATIVE,
922
+
923
+ // Return the rowset at the specified fetch offset.
924
+ // NOT SUPPORTED
925
+ FETCH_ABSOLUTE,
926
+
927
+ // Get the first rowset in the result set.
928
+ FETCH_FIRST,
929
+
930
+ // Get the last rowset in the result set.
931
+ // NOT SUPPORTED
932
+ FETCH_LAST
933
+ }
934
+
935
+ // FetchResults()
936
+ //
937
+ // Fetch rows from the server corresponding to
938
+ // a particular OperationHandle.
939
+ struct TFetchResultsReq {
940
+ // Operation from which to fetch results.
941
+ 1: required TOperationHandle operationHandle
942
+
943
+ // The fetch orientation. For V1 this must be either
944
+ // FETCH_NEXT or FETCH_FIRST. Defaults to FETCH_NEXT.
945
+ 2: required TFetchOrientation orientation = TFetchOrientation.FETCH_NEXT
946
+
947
+ // Max number of rows that should be returned in
948
+ // the rowset.
949
+ 3: required i64 maxRows
950
+ }
951
+
952
+ struct TFetchResultsResp {
953
+ 1: required TStatus status
954
+
955
+ // TRUE if there are more rows left to fetch from the server.
956
+ 2: optional bool hasMoreRows
957
+
958
+ // The rowset. This is optional so that we have the
959
+ // option in the future of adding alternate formats for
960
+ // representing result set data, e.g. delimited strings,
961
+ // binary encoded, etc.
962
+ 3: optional TRowSet results
963
+ }
964
+
965
+ // GetLog()
966
+ //
967
+ // Fetch operation log from the server corresponding to
968
+ // a particular OperationHandle.
969
+ struct TGetLogReq {
970
+ // Operation whose log is requested
971
+ 1: required TOperationHandle operationHandle
972
+ }
973
+
974
+ struct TGetLogResp {
975
+ 1: required TStatus status
976
+
977
+ 2: required string log
978
+ }
979
+
980
+ service TCLIService {
981
+
982
+ TOpenSessionResp OpenSession(1:TOpenSessionReq req);
983
+
984
+ TCloseSessionResp CloseSession(1:TCloseSessionReq req);
985
+
986
+ TGetInfoResp GetInfo(1:TGetInfoReq req);
987
+
988
+ TExecuteStatementResp ExecuteStatement(1:TExecuteStatementReq req);
989
+
990
+ TGetTypeInfoResp GetTypeInfo(1:TGetTypeInfoReq req);
991
+
992
+ TGetCatalogsResp GetCatalogs(1:TGetCatalogsReq req);
993
+
994
+ TGetSchemasResp GetSchemas(1:TGetSchemasReq req);
995
+
996
+ TGetTablesResp GetTables(1:TGetTablesReq req);
997
+
998
+ TGetTableTypesResp GetTableTypes(1:TGetTableTypesReq req);
999
+
1000
+ TGetColumnsResp GetColumns(1:TGetColumnsReq req);
1001
+
1002
+ TGetFunctionsResp GetFunctions(1:TGetFunctionsReq req);
1003
+
1004
+ TGetOperationStatusResp GetOperationStatus(1:TGetOperationStatusReq req);
1005
+
1006
+ TCancelOperationResp CancelOperation(1:TCancelOperationReq req);
1007
+
1008
+ TCloseOperationResp CloseOperation(1:TCloseOperationReq req);
1009
+
1010
+ TGetResultSetMetadataResp GetResultSetMetadata(1:TGetResultSetMetadataReq req);
1011
+
1012
+ TFetchResultsResp FetchResults(1:TFetchResultsReq req);
1013
+
1014
+ TGetLogResp GetLog(1:TGetLogReq req);
1015
+ }