hexspace 0.2.0 → 0.2.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +4 -0
- data/README.md +18 -0
- data/lib/hexspace/client.rb +10 -10
- data/lib/hexspace/result.rb +17 -0
- data/lib/hexspace/version.rb +1 -1
- data/lib/hexspace.rb +1 -0
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b01d38959d851e6e96d16a2230b62e6f659089f855307959a4c27585c32a6550
|
4
|
+
data.tar.gz: 5515be12059303b0e6ee12222caf04896ec8c79b23ffe519b8e9f213f957e257
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7cbfb5be0c692cae31a82b7fc9a817ea443b13549ad92d73ac3d40db371b3ecdba0cc2f7f73dec9407043d5938f00519e6cdc40f990cb9b1cd1c82e544c44e54
|
7
|
+
data.tar.gz: 43fd8714dd9126d3a51246ed7f500a4da7640f2d72c039ea511dfccbd0799bb4103492eccf87ed03ea4dae09eb64c79b20a797e25d84c248596b47319a85f3d8
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -46,6 +46,24 @@ Supported modes are `:sasl`, `:nosasl`, `:http`, and `:https`. Please create an
|
|
46
46
|
|
47
47
|
The timeout is in seconds and only applies to `:sasl` and `:nosasl`.
|
48
48
|
|
49
|
+
## Query Options
|
50
|
+
|
51
|
+
Set a timeout
|
52
|
+
|
53
|
+
```ruby
|
54
|
+
client.execute(statement, timeout: 10)
|
55
|
+
```
|
56
|
+
|
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
|
+
|
49
67
|
## Spark SQL Setup
|
50
68
|
|
51
69
|
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
@@ -48,12 +48,12 @@ module Hexspace
|
|
48
48
|
ObjectSpace.define_finalizer(self, self.class.finalize(@transport, @client, @session))
|
49
49
|
end
|
50
50
|
|
51
|
-
|
52
|
-
# so its possible to get duplicate columns
|
53
|
-
# as well as columns when there are no rows
|
54
|
-
def execute(statement, timeout: nil)
|
51
|
+
def execute(statement, timeout: nil, result_object: false)
|
55
52
|
result = execute_statement(statement, timeout: timeout)
|
56
|
-
|
53
|
+
if result.operationHandle.hasResultSet
|
54
|
+
result = process_result(result)
|
55
|
+
result_object ? result : result.to_a
|
56
|
+
end
|
57
57
|
end
|
58
58
|
|
59
59
|
# private
|
@@ -113,7 +113,7 @@ module Hexspace
|
|
113
113
|
if j == 0
|
114
114
|
new_rows = value.values.size
|
115
115
|
new_rows.times do
|
116
|
-
rows <<
|
116
|
+
rows << []
|
117
117
|
end
|
118
118
|
end
|
119
119
|
|
@@ -130,17 +130,17 @@ module Hexspace
|
|
130
130
|
# end
|
131
131
|
when "date"
|
132
132
|
values.each do |v|
|
133
|
-
rows[offset][
|
133
|
+
rows[offset][j] = nulls[offset] == "1" ? nil : Date.parse(v)
|
134
134
|
offset += 1
|
135
135
|
end
|
136
136
|
when "decimal"
|
137
137
|
values.each do |v|
|
138
|
-
rows[offset][
|
138
|
+
rows[offset][j] = nulls[offset] == "1" ? nil : BigDecimal(v)
|
139
139
|
offset += 1
|
140
140
|
end
|
141
141
|
else
|
142
142
|
values.each do |v|
|
143
|
-
rows[offset][
|
143
|
+
rows[offset][j] = nulls[offset] == "1" ? nil : v
|
144
144
|
offset += 1
|
145
145
|
end
|
146
146
|
end
|
@@ -153,7 +153,7 @@ module Hexspace
|
|
153
153
|
req.operationHandle = stmt.operationHandle
|
154
154
|
check_status client.CloseOperation(req)
|
155
155
|
|
156
|
-
rows
|
156
|
+
Result.new(rows, columns, types)
|
157
157
|
end
|
158
158
|
end
|
159
159
|
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
module Hexspace
|
2
|
+
class Result
|
3
|
+
attr_reader :rows, :columns, :column_types
|
4
|
+
|
5
|
+
def initialize(rows, columns, column_types)
|
6
|
+
@rows = rows
|
7
|
+
@columns = columns
|
8
|
+
@column_types = column_types
|
9
|
+
end
|
10
|
+
|
11
|
+
def to_a
|
12
|
+
@rows.map do |row|
|
13
|
+
@columns.zip(row).to_h
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
data/lib/hexspace/version.rb
CHANGED
data/lib/hexspace.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: hexspace
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Andrew Kane
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-
|
11
|
+
date: 2023-11-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: thrift
|
@@ -35,6 +35,7 @@ files:
|
|
35
35
|
- README.md
|
36
36
|
- lib/hexspace.rb
|
37
37
|
- lib/hexspace/client.rb
|
38
|
+
- lib/hexspace/result.rb
|
38
39
|
- lib/hexspace/sasl_transport.rb
|
39
40
|
- lib/hexspace/tcli_service.rb
|
40
41
|
- lib/hexspace/tcli_service_constants.rb
|