td-client 0.8.52 → 0.8.53

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.
data/ChangeLog CHANGED
@@ -1,3 +1,8 @@
1
+ == 2012-07-22 version 0.8.53
2
+
3
+ * Add normalized_msgpack method to serialize Bignum type
4
+
5
+
1
6
  == 2012-06-24 version 0.8.52
2
7
 
3
8
  * Add last_log_timestamp to Table model
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, "only 'hive' and 'pig' types are supported" unless [:hive, :pig].include? type
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?
@@ -1,5 +1,5 @@
1
1
  module TreasureData
2
2
  class Client
3
- VERSION = '0.8.52'
3
+ VERSION = '0.8.53'
4
4
  end
5
5
  end
data/spec/spec_helper.rb CHANGED
@@ -13,6 +13,7 @@ include WebMock::API
13
13
 
14
14
  $LOAD_PATH << File.dirname(__FILE__)+"../lib"
15
15
  require 'td-client'
16
+ require 'msgpack'
16
17
 
17
18
  include TreasureData
18
19
 
@@ -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.52
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-06-24 00:00:00.000000000 Z
12
+ date: 2013-07-22 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: msgpack