td-client 0.8.61 → 0.8.62
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +13 -5
- data/lib/td/client/api.rb +38 -11
- data/lib/td/client/model.rb +14 -12
- data/lib/td/client/version.rb +1 -1
- data/spec/api_spec.rb +5 -5
- metadata +28 -28
checksums.yaml
CHANGED
@@ -1,7 +1,15 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
|
2
|
+
!binary "U0hBMQ==":
|
3
|
+
metadata.gz: !binary |-
|
4
|
+
NDRiYWJjYzc1NDFiOTQzMzBkNjNmMGUwNDcxMDAzOWQ5Njg0NzVmNA==
|
5
|
+
data.tar.gz: !binary |-
|
6
|
+
Y2JkMzE0NTBhNWQ4YzZiZjY0MDY2ZmY4MmE2YmY4NWYzYmY2N2Q1NA==
|
5
7
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
|
8
|
+
metadata.gz: !binary |-
|
9
|
+
NTllMjQzNDUyOGVkNWM1MWMxNDY5YWMwOGE4ODNjM2M5N2ZjYjZhYWUzZWQ1
|
10
|
+
YTFlMmMyMzNkNjExZGFjOWUyMzMxODM3ZGQ4YjQ2ZGUzYWZhYzEwY2M3OWE4
|
11
|
+
ODA5ODI2NTQzNGE4ZDM0OTdiMzNjOGNlODFhNzZlNDU3YTY4M2Q=
|
12
|
+
data.tar.gz: !binary |-
|
13
|
+
MjVhNmU2MmI5NDNlZDliNDU1YzQzNjdmYzkwYWQ0YWU2ZWRjMWJjMDE0ZTdl
|
14
|
+
ZDgyMGYxY2Y3OTI4NmM4MDcwODJjMmJkNmE2NThiMGFkYzEyM2VjNTc0NzNh
|
15
|
+
MjQyMWI2MTFiOGIxYTgzNmEzZTEwYjc0NTNmOTVjYjcwZGMwNDk=
|
data/lib/td/client/api.rb
CHANGED
@@ -51,7 +51,9 @@ class API
|
|
51
51
|
when 'http', 'https'
|
52
52
|
@host = uri.host
|
53
53
|
@port = uri.port
|
54
|
-
|
54
|
+
# the opts[:ssl] option is ignored here, it's value
|
55
|
+
# overridden by the scheme of the endpoint URI
|
56
|
+
@ssl = (uri.scheme == 'https')
|
55
57
|
@base_path = uri.path.to_s
|
56
58
|
|
57
59
|
else
|
@@ -80,7 +82,7 @@ class API
|
|
80
82
|
else
|
81
83
|
@http_proxy
|
82
84
|
end
|
83
|
-
proxy_host, proxy_port = http_proxy.split(':',2)
|
85
|
+
proxy_host, proxy_port = http_proxy.split(':', 2)
|
84
86
|
proxy_port = (proxy_port ? proxy_port.to_i : 80)
|
85
87
|
@http_class = Net::HTTP::Proxy(proxy_host, proxy_port)
|
86
88
|
else
|
@@ -129,19 +131,19 @@ class API
|
|
129
131
|
end
|
130
132
|
|
131
133
|
def self.validate_database_name(name)
|
132
|
-
validate_name("database", 3,
|
134
|
+
validate_name("database", 3, 255, name)
|
133
135
|
end
|
134
136
|
|
135
137
|
def self.validate_table_name(name)
|
136
|
-
validate_name("table", 3,
|
138
|
+
validate_name("table", 3, 255, name)
|
137
139
|
end
|
138
140
|
|
139
141
|
def self.validate_result_set_name(name)
|
140
|
-
validate_name("result set", 3,
|
142
|
+
validate_name("result set", 3, 255, name)
|
141
143
|
end
|
142
144
|
|
143
145
|
def self.validate_column_name(name)
|
144
|
-
validate_name("column",
|
146
|
+
validate_name("column", 1, 255, name)
|
145
147
|
end
|
146
148
|
|
147
149
|
def self.normalize_database_name(name)
|
@@ -150,10 +152,10 @@ class API
|
|
150
152
|
raise "Empty name is not allowed"
|
151
153
|
end
|
152
154
|
if name.length < 3
|
153
|
-
name += "_"*(3-name.length)
|
155
|
+
name += "_" * (3 - name.length)
|
154
156
|
end
|
155
157
|
if 256 < name.length
|
156
|
-
name = name[0,254]+"__"
|
158
|
+
name = name[0,254] + "__"
|
157
159
|
end
|
158
160
|
name = name.downcase
|
159
161
|
name = name.gsub(/[^a-z0-9_]/, '_')
|
@@ -448,11 +450,36 @@ class API
|
|
448
450
|
if hive_result_schema.empty?
|
449
451
|
hive_result_schema = nil
|
450
452
|
else
|
451
|
-
|
453
|
+
begin
|
454
|
+
hive_result_schema = JSON.parse(hive_result_schema)
|
455
|
+
rescue JSON::ParserError => e
|
456
|
+
# this is a workaround for a Known Limitation in the Pig Engine which does not set a default, auto-generated
|
457
|
+
# column name for anonymous columns (such as the ones that are generated from UDF like COUNT or SUM).
|
458
|
+
# The schema will contain 'nil' for the name of those columns and that breaks the JSON parser since it violates
|
459
|
+
# the JSON syntax standard.
|
460
|
+
if type == :pig and hive_result_schema !~ /[\{\}]/
|
461
|
+
begin
|
462
|
+
# NOTE: this works because a JSON 2 dimensional array is the same as a Ruby one.
|
463
|
+
# Any change in the format for the hive_result_schema output may cause a syntax error, in which case
|
464
|
+
# this lame attempt at fixing the problem will fail and we will be raising the original JSON exception
|
465
|
+
hive_result_schema = eval(hive_result_schema)
|
466
|
+
rescue SyntaxError => ignored_e
|
467
|
+
raise e
|
468
|
+
end
|
469
|
+
hive_result_schema.each_with_index {|col_schema, idx|
|
470
|
+
if col_schema[0].nil?
|
471
|
+
col_schema[0] = "_col#{idx}"
|
472
|
+
end
|
473
|
+
}
|
474
|
+
else
|
475
|
+
raise e
|
476
|
+
end
|
477
|
+
end
|
452
478
|
end
|
453
479
|
priority = js['priority']
|
454
480
|
retry_limit = js['retry_limit']
|
455
|
-
return [type, query, status, url, debug, start_at, end_at, cpu_time, result,
|
481
|
+
return [type, query, status, url, debug, start_at, end_at, cpu_time, result,
|
482
|
+
hive_result_schema, priority, retry_limit, nil, database]
|
456
483
|
end
|
457
484
|
|
458
485
|
def job_status(job_id)
|
@@ -933,7 +960,7 @@ class API
|
|
933
960
|
result = js["users"].map {|roleinfo|
|
934
961
|
name = roleinfo['name']
|
935
962
|
email = roleinfo['email']
|
936
|
-
[name, nil, nil, email] # set nil to org and role for API
|
963
|
+
[name, nil, nil, email] # set nil to org and role for API compatibility
|
937
964
|
}
|
938
965
|
return result
|
939
966
|
end
|
data/lib/td/client/model.rb
CHANGED
@@ -331,30 +331,32 @@ class Job < Model
|
|
331
331
|
|
332
332
|
def finished?
|
333
333
|
update_progress! unless @status
|
334
|
-
|
335
|
-
return true
|
336
|
-
else
|
337
|
-
return false
|
338
|
-
end
|
339
|
-
end
|
340
|
-
|
341
|
-
def running?
|
342
|
-
!finished?
|
334
|
+
FINISHED_STATUS.include?(@status)
|
343
335
|
end
|
344
336
|
|
345
337
|
def success?
|
346
338
|
update_progress! unless @status
|
347
|
-
@status ==
|
339
|
+
@status == STATUS_SUCCESS
|
348
340
|
end
|
349
341
|
|
350
342
|
def error?
|
351
343
|
update_progress! unless @status
|
352
|
-
@status ==
|
344
|
+
@status == STATUS_ERROR
|
353
345
|
end
|
354
346
|
|
355
347
|
def killed?
|
356
348
|
update_progress! unless @status
|
357
|
-
@status ==
|
349
|
+
@status == STATUS_KILLED
|
350
|
+
end
|
351
|
+
|
352
|
+
def queued?
|
353
|
+
update_progress! unless @status
|
354
|
+
@status == STATUS_QUEUED
|
355
|
+
end
|
356
|
+
|
357
|
+
def running?
|
358
|
+
update_progress! unless @status
|
359
|
+
@status == STATUS_RUNNING
|
358
360
|
end
|
359
361
|
|
360
362
|
def update_progress!
|
data/lib/td/client/version.rb
CHANGED
data/spec/api_spec.rb
CHANGED
@@ -12,7 +12,7 @@ describe API do
|
|
12
12
|
|
13
13
|
INVALID_NAMES = {
|
14
14
|
'a' => 'a__',
|
15
|
-
'a'*
|
15
|
+
'a' * 256 => 'a' * 253 + '__',
|
16
16
|
'abcD' => 'abcd',
|
17
17
|
'a-b*' => 'a_b_',
|
18
18
|
}
|
@@ -39,22 +39,22 @@ describe API do
|
|
39
39
|
INVALID_NAMES.each_pair {|ng,ok|
|
40
40
|
lambda {
|
41
41
|
API.validate_database_name(ng)
|
42
|
-
}.should raise_error(
|
42
|
+
}.should raise_error(ParameterValidationError)
|
43
43
|
}
|
44
44
|
lambda {
|
45
45
|
API.validate_database_name('')
|
46
|
-
}.should raise_error(
|
46
|
+
}.should raise_error(ParameterValidationError)
|
47
47
|
end
|
48
48
|
|
49
49
|
it 'validate_table_name should raise errors' do
|
50
50
|
INVALID_NAMES.each_pair {|ng,ok|
|
51
51
|
lambda {
|
52
52
|
API.validate_table_name(ng)
|
53
|
-
}.should raise_error(
|
53
|
+
}.should raise_error(ParameterValidationError)
|
54
54
|
}
|
55
55
|
lambda {
|
56
56
|
API.validate_table_name('')
|
57
|
-
}.should raise_error(
|
57
|
+
}.should raise_error(ParameterValidationError)
|
58
58
|
end
|
59
59
|
|
60
60
|
it 'normalize_database_name should return valid data' do
|
metadata
CHANGED
@@ -1,141 +1,141 @@
|
|
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.62
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Treasure Data, Inc.
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-06-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: msgpack
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- -
|
17
|
+
- - ! '>='
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: 0.4.4
|
20
|
-
- -
|
20
|
+
- - ! '!='
|
21
21
|
- !ruby/object:Gem::Version
|
22
22
|
version: 0.5.0
|
23
|
-
- -
|
23
|
+
- - ! '!='
|
24
24
|
- !ruby/object:Gem::Version
|
25
25
|
version: 0.5.1
|
26
|
-
- -
|
26
|
+
- - ! '!='
|
27
27
|
- !ruby/object:Gem::Version
|
28
28
|
version: 0.5.2
|
29
|
-
- -
|
29
|
+
- - ! '!='
|
30
30
|
- !ruby/object:Gem::Version
|
31
31
|
version: 0.5.3
|
32
|
-
- -
|
32
|
+
- - <
|
33
33
|
- !ruby/object:Gem::Version
|
34
34
|
version: 0.6.0
|
35
35
|
type: :runtime
|
36
36
|
prerelease: false
|
37
37
|
version_requirements: !ruby/object:Gem::Requirement
|
38
38
|
requirements:
|
39
|
-
- -
|
39
|
+
- - ! '>='
|
40
40
|
- !ruby/object:Gem::Version
|
41
41
|
version: 0.4.4
|
42
|
-
- -
|
42
|
+
- - ! '!='
|
43
43
|
- !ruby/object:Gem::Version
|
44
44
|
version: 0.5.0
|
45
|
-
- -
|
45
|
+
- - ! '!='
|
46
46
|
- !ruby/object:Gem::Version
|
47
47
|
version: 0.5.1
|
48
|
-
- -
|
48
|
+
- - ! '!='
|
49
49
|
- !ruby/object:Gem::Version
|
50
50
|
version: 0.5.2
|
51
|
-
- -
|
51
|
+
- - ! '!='
|
52
52
|
- !ruby/object:Gem::Version
|
53
53
|
version: 0.5.3
|
54
|
-
- -
|
54
|
+
- - <
|
55
55
|
- !ruby/object:Gem::Version
|
56
56
|
version: 0.6.0
|
57
57
|
- !ruby/object:Gem::Dependency
|
58
58
|
name: json
|
59
59
|
requirement: !ruby/object:Gem::Requirement
|
60
60
|
requirements:
|
61
|
-
- -
|
61
|
+
- - ! '>='
|
62
62
|
- !ruby/object:Gem::Version
|
63
63
|
version: 1.7.6
|
64
64
|
type: :runtime
|
65
65
|
prerelease: false
|
66
66
|
version_requirements: !ruby/object:Gem::Requirement
|
67
67
|
requirements:
|
68
|
-
- -
|
68
|
+
- - ! '>='
|
69
69
|
- !ruby/object:Gem::Version
|
70
70
|
version: 1.7.6
|
71
71
|
- !ruby/object:Gem::Dependency
|
72
72
|
name: httpclient
|
73
73
|
requirement: !ruby/object:Gem::Requirement
|
74
74
|
requirements:
|
75
|
-
- -
|
75
|
+
- - ~>
|
76
76
|
- !ruby/object:Gem::Version
|
77
77
|
version: 2.3.4
|
78
78
|
type: :runtime
|
79
79
|
prerelease: false
|
80
80
|
version_requirements: !ruby/object:Gem::Requirement
|
81
81
|
requirements:
|
82
|
-
- -
|
82
|
+
- - ~>
|
83
83
|
- !ruby/object:Gem::Version
|
84
84
|
version: 2.3.4
|
85
85
|
- !ruby/object:Gem::Dependency
|
86
86
|
name: rspec
|
87
87
|
requirement: !ruby/object:Gem::Requirement
|
88
88
|
requirements:
|
89
|
-
- -
|
89
|
+
- - ~>
|
90
90
|
- !ruby/object:Gem::Version
|
91
91
|
version: '2.8'
|
92
92
|
type: :development
|
93
93
|
prerelease: false
|
94
94
|
version_requirements: !ruby/object:Gem::Requirement
|
95
95
|
requirements:
|
96
|
-
- -
|
96
|
+
- - ~>
|
97
97
|
- !ruby/object:Gem::Version
|
98
98
|
version: '2.8'
|
99
99
|
- !ruby/object:Gem::Dependency
|
100
100
|
name: webmock
|
101
101
|
requirement: !ruby/object:Gem::Requirement
|
102
102
|
requirements:
|
103
|
-
- -
|
103
|
+
- - ~>
|
104
104
|
- !ruby/object:Gem::Version
|
105
105
|
version: '1.16'
|
106
106
|
type: :development
|
107
107
|
prerelease: false
|
108
108
|
version_requirements: !ruby/object:Gem::Requirement
|
109
109
|
requirements:
|
110
|
-
- -
|
110
|
+
- - ~>
|
111
111
|
- !ruby/object:Gem::Version
|
112
112
|
version: '1.16'
|
113
113
|
- !ruby/object:Gem::Dependency
|
114
114
|
name: simplecov
|
115
115
|
requirement: !ruby/object:Gem::Requirement
|
116
116
|
requirements:
|
117
|
-
- -
|
117
|
+
- - ! '>='
|
118
118
|
- !ruby/object:Gem::Version
|
119
119
|
version: 0.5.4
|
120
120
|
type: :development
|
121
121
|
prerelease: false
|
122
122
|
version_requirements: !ruby/object:Gem::Requirement
|
123
123
|
requirements:
|
124
|
-
- -
|
124
|
+
- - ! '>='
|
125
125
|
- !ruby/object:Gem::Version
|
126
126
|
version: 0.5.4
|
127
127
|
- !ruby/object:Gem::Dependency
|
128
128
|
name: rake
|
129
129
|
requirement: !ruby/object:Gem::Requirement
|
130
130
|
requirements:
|
131
|
-
- -
|
131
|
+
- - ! '>='
|
132
132
|
- !ruby/object:Gem::Version
|
133
133
|
version: '0'
|
134
134
|
type: :development
|
135
135
|
prerelease: false
|
136
136
|
version_requirements: !ruby/object:Gem::Requirement
|
137
137
|
requirements:
|
138
|
-
- -
|
138
|
+
- - ! '>='
|
139
139
|
- !ruby/object:Gem::Version
|
140
140
|
version: '0'
|
141
141
|
description: Treasure Data API library for Ruby
|
@@ -171,12 +171,12 @@ require_paths:
|
|
171
171
|
- lib
|
172
172
|
required_ruby_version: !ruby/object:Gem::Requirement
|
173
173
|
requirements:
|
174
|
-
- -
|
174
|
+
- - ! '>='
|
175
175
|
- !ruby/object:Gem::Version
|
176
176
|
version: '0'
|
177
177
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
178
178
|
requirements:
|
179
|
-
- -
|
179
|
+
- - ! '>='
|
180
180
|
- !ruby/object:Gem::Version
|
181
181
|
version: '0'
|
182
182
|
requirements: []
|