hexspace 0.1.0 → 0.1.1
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 +5 -0
- data/README.md +7 -1
- data/lib/hexspace.rb +4 -0
- data/lib/hexspace/client.rb +35 -7
- data/lib/hexspace/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 46cb7c0c6c1d1839a2672e99b5daedfd952e0f31ef9fdeabe055f980c8f52aca
|
4
|
+
data.tar.gz: c16be8b8145beed444821a83b018f1d77a63db01947c1bdf6e34923bb64bc919
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2badf30752d561592c909ec3eb15b3967b0b551479563a1972742a310e5c5da297e8beb58626e14177ab894efc16645b74337bc6f64c3fd1afb80ed861fffcac
|
7
|
+
data.tar.gz: 92405d6ba47f7b3b5841250cc09638f4b44d487206a37f5dac1d8deb70ede1fb504a2635456a9e0c88a40b9e930840d6b0a8c76b4863bf658ea031ddd084dbca
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -23,7 +23,7 @@ client = Hexspace::Client.new
|
|
23
23
|
Execute queries
|
24
24
|
|
25
25
|
```ruby
|
26
|
-
client.execute("SELECT
|
26
|
+
client.execute("SELECT COUNT(*) FROM users")
|
27
27
|
```
|
28
28
|
|
29
29
|
## Connection Options
|
@@ -96,3 +96,9 @@ beeline -u jdbc:hive2://localhost:10000 -e 'CREATE DATABASE hexspace_test;'
|
|
96
96
|
# run the tests
|
97
97
|
bundle exec rake test
|
98
98
|
```
|
99
|
+
|
100
|
+
Resources
|
101
|
+
|
102
|
+
- [Spark SQL Reference](https://spark.apache.org/docs/latest/sql-ref.html)
|
103
|
+
- [Hive Language Manual](https://cwiki.apache.org/confluence/display/Hive/LanguageManual)
|
104
|
+
- [Thrift SASL Spec](https://github.com/apache/thrift/blob/master/doc/specs/thrift-sasl-spec.txt)
|
data/lib/hexspace.rb
CHANGED
data/lib/hexspace/client.rb
CHANGED
@@ -36,18 +36,24 @@ module Hexspace
|
|
36
36
|
@client = TCLIService::Client.new(protocol)
|
37
37
|
|
38
38
|
req = TOpenSessionReq.new
|
39
|
-
|
40
|
-
|
41
|
-
|
39
|
+
configuration = {
|
40
|
+
# remove table prefix with Hive
|
41
|
+
"set:hiveconf:hive.resultset.use.unique.column.names" => "false"
|
42
|
+
}
|
43
|
+
configuration["use:database"] = database if database
|
44
|
+
req.configuration = configuration
|
42
45
|
@session = @client.OpenSession(req)
|
43
46
|
check_status @session
|
44
47
|
|
45
48
|
ObjectSpace.define_finalizer(self, self.class.finalize(@transport, @client, @session))
|
46
49
|
end
|
47
50
|
|
51
|
+
# TODO add new method that returns Result object
|
52
|
+
# so its possible to get duplicate columns
|
53
|
+
# as well as columns when there are no rows
|
48
54
|
def execute(statement, timeout: nil)
|
49
55
|
result = execute_statement(statement, timeout: timeout)
|
50
|
-
process_result(result)
|
56
|
+
process_result(result) if result.operationHandle.hasResultSet
|
51
57
|
end
|
52
58
|
|
53
59
|
# private
|
@@ -87,6 +93,7 @@ module Hexspace
|
|
87
93
|
|
88
94
|
rows = []
|
89
95
|
columns = metadata.schema.columns.map(&:columnName)
|
96
|
+
types = metadata.schema.columns.map { |c| TYPE_NAMES[c.typeDesc.types.first.primitiveEntry.type].downcase }
|
90
97
|
|
91
98
|
loop do
|
92
99
|
req = TFetchResultsReq.new
|
@@ -111,9 +118,30 @@ module Hexspace
|
|
111
118
|
|
112
119
|
offset = start_offset
|
113
120
|
nulls = value.nulls.unpack1("b*")
|
114
|
-
value.values
|
115
|
-
|
116
|
-
|
121
|
+
values = value.values
|
122
|
+
|
123
|
+
case types[j]
|
124
|
+
# TODO decide how to handle time zones
|
125
|
+
# when "timestamp"
|
126
|
+
# values.each do |v|
|
127
|
+
# rows[offset][name] = nulls[offset] == "1" ? nil : Time.parse(v)
|
128
|
+
# offset += 1
|
129
|
+
# end
|
130
|
+
when "date"
|
131
|
+
values.each do |v|
|
132
|
+
rows[offset][name] = nulls[offset] == "1" ? nil : Date.parse(v)
|
133
|
+
offset += 1
|
134
|
+
end
|
135
|
+
when "decimal"
|
136
|
+
values.each do |v|
|
137
|
+
rows[offset][name] = nulls[offset] == "1" ? nil : BigDecimal(v)
|
138
|
+
offset += 1
|
139
|
+
end
|
140
|
+
else
|
141
|
+
values.each do |v|
|
142
|
+
rows[offset][name] = nulls[offset] == "1" ? nil : v
|
143
|
+
offset += 1
|
144
|
+
end
|
117
145
|
end
|
118
146
|
end
|
119
147
|
|
data/lib/hexspace/version.rb
CHANGED