hexspace 0.2.0 → 0.2.2
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 +8 -0
- data/README.md +19 -1
- 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 +2 -1
- metadata +18 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3d21bbeba05778ebceedf12cde6444e13c651aa1e4046a6959255d2e9f38aa26
|
4
|
+
data.tar.gz: e2aa5546583c0d7c5030b29e4fdca0cbb7caa013a00eafe51ba997b6fe576091
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cd5eaa3d37ce89e12a2b655a252c543e6c3c430230f764b0e34742c48221af6a68170e58e04d9620a03f46fc626d1065c1a1f1ecda957f21ad12d9bcb0810abc
|
7
|
+
data.tar.gz: d4ddeb31b86a14dea33cc7ca798aca9e5af788f04b7e194c88dc0e21e503082bef7c4c1562c02fc4df9e1b2e4832af8e09a523a338ca5e54935f5a8ac5ee3d69
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
Ruby client for Apache Spark SQL and Apache Hive
|
4
4
|
|
5
|
-
[](https://github.com/ankane/hexspace/actions)
|
6
6
|
|
7
7
|
## Installation
|
8
8
|
|
@@ -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
@@ -1,8 +1,8 @@
|
|
1
1
|
# dependencies
|
2
|
+
require "bigdecimal"
|
2
3
|
require "thrift"
|
3
4
|
|
4
5
|
# stdlib
|
5
|
-
require "bigdecimal"
|
6
6
|
require "time"
|
7
7
|
|
8
8
|
# thrift
|
@@ -12,6 +12,7 @@ require_relative "hexspace/tcli_service"
|
|
12
12
|
|
13
13
|
# modules
|
14
14
|
require_relative "hexspace/client"
|
15
|
+
require_relative "hexspace/result"
|
15
16
|
require_relative "hexspace/sasl_transport"
|
16
17
|
require_relative "hexspace/version"
|
17
18
|
|
metadata
CHANGED
@@ -1,15 +1,28 @@
|
|
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.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Andrew Kane
|
8
|
-
autorequire:
|
9
8
|
bindir: bin
|
10
9
|
cert_chain: []
|
11
|
-
date:
|
10
|
+
date: 2024-12-29 00:00:00.000000000 Z
|
12
11
|
dependencies:
|
12
|
+
- !ruby/object:Gem::Dependency
|
13
|
+
name: bigdecimal
|
14
|
+
requirement: !ruby/object:Gem::Requirement
|
15
|
+
requirements:
|
16
|
+
- - ">="
|
17
|
+
- !ruby/object:Gem::Version
|
18
|
+
version: '0'
|
19
|
+
type: :runtime
|
20
|
+
prerelease: false
|
21
|
+
version_requirements: !ruby/object:Gem::Requirement
|
22
|
+
requirements:
|
23
|
+
- - ">="
|
24
|
+
- !ruby/object:Gem::Version
|
25
|
+
version: '0'
|
13
26
|
- !ruby/object:Gem::Dependency
|
14
27
|
name: thrift
|
15
28
|
requirement: !ruby/object:Gem::Requirement
|
@@ -24,7 +37,6 @@ dependencies:
|
|
24
37
|
- - ">="
|
25
38
|
- !ruby/object:Gem::Version
|
26
39
|
version: '0.18'
|
27
|
-
description:
|
28
40
|
email: andrew@ankane.org
|
29
41
|
executables: []
|
30
42
|
extensions: []
|
@@ -35,6 +47,7 @@ files:
|
|
35
47
|
- README.md
|
36
48
|
- lib/hexspace.rb
|
37
49
|
- lib/hexspace/client.rb
|
50
|
+
- lib/hexspace/result.rb
|
38
51
|
- lib/hexspace/sasl_transport.rb
|
39
52
|
- lib/hexspace/tcli_service.rb
|
40
53
|
- lib/hexspace/tcli_service_constants.rb
|
@@ -44,7 +57,6 @@ homepage: https://github.com/ankane/hexspace
|
|
44
57
|
licenses:
|
45
58
|
- Apache-2.0
|
46
59
|
metadata: {}
|
47
|
-
post_install_message:
|
48
60
|
rdoc_options: []
|
49
61
|
require_paths:
|
50
62
|
- lib
|
@@ -59,8 +71,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
59
71
|
- !ruby/object:Gem::Version
|
60
72
|
version: '0'
|
61
73
|
requirements: []
|
62
|
-
rubygems_version: 3.
|
63
|
-
signing_key:
|
74
|
+
rubygems_version: 3.6.2
|
64
75
|
specification_version: 4
|
65
76
|
summary: Ruby client for Apache Spark SQL and Apache Hive
|
66
77
|
test_files: []
|