td-client 0.8.52 → 0.8.53
Sign up to get free protection for your applications and to get access to all the features.
- data/ChangeLog +5 -0
- data/lib/td/client.rb +1 -1
- data/lib/td/client/api.rb +10 -0
- data/lib/td/client/version.rb +1 -1
- data/spec/spec_helper.rb +1 -0
- data/spec/td/client/api_spec.rb +14 -0
- metadata +2 -2
data/ChangeLog
CHANGED
data/lib/td/client.rb
CHANGED
@@ -124,7 +124,7 @@ class Client
|
|
124
124
|
def query(db_name, q, result_url=nil, priority=nil, retry_limit=nil, opts={})
|
125
125
|
# for compatibility, assume type is hive unless specifically specified
|
126
126
|
type = opts[:type] || opts['type'] || :hive
|
127
|
-
raise ArgumentError, "
|
127
|
+
raise ArgumentError, "The specified query type is not supported: #{type}" unless [:hive, :pig, :impala].include? type
|
128
128
|
job_id = @api.query(q, type, db_name, result_url, priority, retry_limit, opts)
|
129
129
|
Job.new(self, job_id, type, q)
|
130
130
|
end
|
data/lib/td/client/api.rb
CHANGED
@@ -78,6 +78,16 @@ class API
|
|
78
78
|
|
79
79
|
attr_reader :apikey
|
80
80
|
|
81
|
+
def self.normalized_msgpack(record, out = nil)
|
82
|
+
record.keys.each { |k|
|
83
|
+
v = record[k]
|
84
|
+
if v.kind_of?(Bignum)
|
85
|
+
record[k] = v.to_s
|
86
|
+
end
|
87
|
+
}
|
88
|
+
record.to_msgpack(out)
|
89
|
+
end
|
90
|
+
|
81
91
|
def self.validate_database_name(name)
|
82
92
|
name = name.to_s
|
83
93
|
if name.empty?
|
data/lib/td/client/version.rb
CHANGED
data/spec/spec_helper.rb
CHANGED
data/spec/td/client/api_spec.rb
CHANGED
@@ -24,6 +24,20 @@ describe API do
|
|
24
24
|
}
|
25
25
|
|
26
26
|
describe 'normalizer' do
|
27
|
+
it 'normalized_msgpack should convert Bignum into String' do
|
28
|
+
h = {'key' => 1111111111111111111111111111111111}
|
29
|
+
unpacked = MessagePack.unpack(API.normalized_msgpack(h))
|
30
|
+
expect(unpacked['key']).to eq(h['key'].to_s)
|
31
|
+
end
|
32
|
+
|
33
|
+
it 'normalized_msgpack with out argument should convert Bignum into String' do
|
34
|
+
h = {'key' => 1111111111111111111111111111111111}
|
35
|
+
out = ''
|
36
|
+
API.normalized_msgpack(h, out)
|
37
|
+
unpacked = MessagePack.unpack(out)
|
38
|
+
expect(unpacked['key']).to eq(h['key'].to_s)
|
39
|
+
end
|
40
|
+
|
27
41
|
it 'normalize_database_name should return normalized data' do
|
28
42
|
INVALID_NAMES.each_pair {|ng,ok|
|
29
43
|
API.normalize_database_name(ng).should == ok
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: td-client
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.8.
|
4
|
+
version: 0.8.53
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-
|
12
|
+
date: 2013-07-22 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: msgpack
|