hexspace 0.2.2 → 0.4.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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +9 -0
- data/README.md +5 -11
- data/lib/hexspace/client.rb +2 -3
- data/lib/hexspace/result.rb +5 -3
- data/lib/hexspace/tcli_service.rb +525 -317
- data/lib/hexspace/tcli_service_constants.rb +49 -47
- data/lib/hexspace/tcli_service_types.rb +785 -517
- data/lib/hexspace/version.rb +1 -1
- metadata +6 -6
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 662a45aba18fe6a936d6ce153a590237330def782ad7a82e0ce2d0934f528c2c
|
|
4
|
+
data.tar.gz: 5f996fbe8ab11c0a44b7a1a2ce71670fef27ec0285cbd6e0a956427fa136e530
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 89dd9a8744ab44690461993c6149ea31249f5ef5ebdcf0003b36d2203ebc973f5e84c9ed298136c33beacceec18b2693b704d0abcbd24887bf5df4165142bf2e
|
|
7
|
+
data.tar.gz: 1310f8d984c6bc0fd5af5941b6287583c291961c3f12af1205a09654c0e200e15399ad044f17734da96cda4be7b27f0934fd3deddc3d5939456ad2dfd42e9bf7
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
|
@@ -23,7 +23,11 @@ client = Hexspace::Client.new
|
|
|
23
23
|
Execute queries
|
|
24
24
|
|
|
25
25
|
```ruby
|
|
26
|
-
client.execute("SELECT COUNT(*) FROM users")
|
|
26
|
+
result = client.execute("SELECT COUNT(*) FROM users")
|
|
27
|
+
result.rows
|
|
28
|
+
result.columns
|
|
29
|
+
result.column_types
|
|
30
|
+
result.to_a
|
|
27
31
|
```
|
|
28
32
|
|
|
29
33
|
## Connection Options
|
|
@@ -54,16 +58,6 @@ Set a timeout
|
|
|
54
58
|
client.execute(statement, timeout: 10)
|
|
55
59
|
```
|
|
56
60
|
|
|
57
|
-
Get a `Hexspace::Result` object instead of an array of hashes
|
|
58
|
-
|
|
59
|
-
```ruby
|
|
60
|
-
result = client.execute(statement, result_object: true)
|
|
61
|
-
result.rows
|
|
62
|
-
result.columns
|
|
63
|
-
result.column_types
|
|
64
|
-
result.to_a
|
|
65
|
-
```
|
|
66
|
-
|
|
67
61
|
## Spark SQL Setup
|
|
68
62
|
|
|
69
63
|
Download [Apache Spark](https://spark.apache.org/downloads.html) and start the [Thift server](https://spark.apache.org/docs/latest/sql-distributed-sql-engine.html).
|
data/lib/hexspace/client.rb
CHANGED
|
@@ -25,7 +25,7 @@ module Hexspace
|
|
|
25
25
|
uri = uri_class.build(host: host, port: port || 10001, path: "/cliservice")
|
|
26
26
|
|
|
27
27
|
t = Thrift::HTTPClientTransport.new(uri)
|
|
28
|
-
t.add_headers({"Authorization" => "Basic #{
|
|
28
|
+
t.add_headers({"Authorization" => "Basic #{["#{username}:#{password}"].pack("m0")}"})
|
|
29
29
|
t
|
|
30
30
|
else
|
|
31
31
|
raise ArgumentError, "Invalid mode: #{mode}"
|
|
@@ -48,7 +48,7 @@ module Hexspace
|
|
|
48
48
|
ObjectSpace.define_finalizer(self, self.class.finalize(@transport, @client, @session))
|
|
49
49
|
end
|
|
50
50
|
|
|
51
|
-
def execute(statement, timeout: nil, result_object:
|
|
51
|
+
def execute(statement, timeout: nil, result_object: true)
|
|
52
52
|
result = execute_statement(statement, timeout: timeout)
|
|
53
53
|
if result.operationHandle.hasResultSet
|
|
54
54
|
result = process_result(result)
|
|
@@ -107,7 +107,6 @@ module Hexspace
|
|
|
107
107
|
|
|
108
108
|
# columns can be nil with Spark 3.4+
|
|
109
109
|
result.results.columns&.each_with_index do |col, j|
|
|
110
|
-
name = columns[j]
|
|
111
110
|
value = col.get_value
|
|
112
111
|
|
|
113
112
|
if j == 0
|
data/lib/hexspace/result.rb
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
module Hexspace
|
|
2
2
|
class Result
|
|
3
|
+
include Enumerable
|
|
4
|
+
|
|
3
5
|
attr_reader :rows, :columns, :column_types
|
|
4
6
|
|
|
5
7
|
def initialize(rows, columns, column_types)
|
|
@@ -8,9 +10,9 @@ module Hexspace
|
|
|
8
10
|
@column_types = column_types
|
|
9
11
|
end
|
|
10
12
|
|
|
11
|
-
def
|
|
12
|
-
@rows.
|
|
13
|
-
@columns.zip(row).to_h
|
|
13
|
+
def each
|
|
14
|
+
@rows.each do |row|
|
|
15
|
+
yield @columns.zip(row).to_h
|
|
14
16
|
end
|
|
15
17
|
end
|
|
16
18
|
end
|