td 0.15.7 → 0.15.8

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 7bb4903ebbe92100825f6fb8c768a4b43135e32e
4
- data.tar.gz: 6c2fce67432e0d56d536971b5b75e164d88a8bc4
3
+ metadata.gz: a279860c461d45d5c1f7450e7b892ffcad60b5bd
4
+ data.tar.gz: c03240d59c09335f2dc2985011c79b73a00e6389
5
5
  SHA512:
6
- metadata.gz: 39f2f0b420f772c670990e1303a037f626bf989c208a75103724fbc24359755335d68fc1623b1c8aaadbcca964280164aea34636cbde90eb653c298274bf6462
7
- data.tar.gz: 0c4b3cc6037493a693d8d283160136bd2b7bda2f701aaab7705895322285bc388df348646245d96e214c5f338298904fbacca113bed86477945dccf9a7ae1126
6
+ metadata.gz: '09b2934ab370519543a1b422ec7afdefcc1a9e2ec6f1511e08f214d9bf440f14d785a45eabd4028bd43c2765d819f300d8180eacab98b76f83ab05dc36eca33b'
7
+ data.tar.gz: 989748a1001685d4dfa1ed47c046fe08e888377631171e9a52bd1e87aa50d66cd766b7ebb6367522c19dc648e64d5fbea11fe68ab055ef46a06e57b99a1c447e
data/.travis.yml CHANGED
@@ -5,8 +5,9 @@ jdk:
5
5
 
6
6
  rvm:
7
7
  - 2.1.10
8
- - 2.2.5
9
- - 2.3.1
8
+ - 2.2.9
9
+ - 2.3.6
10
+ - 2.4.3
10
11
  - ruby-head
11
12
 
12
13
  gemfile:
data/ChangeLog CHANGED
@@ -1,3 +1,10 @@
1
+ == 2018-01-22 version 0.15.8
2
+
3
+ * table:update to update table options #196
4
+ * Avoid extra API call on job:list #199
5
+ * td workflow supports non US region and Private Connect #197 #198
6
+ * fix sched:history -p causes missing one record #195
7
+
1
8
  == 2017-10-24 version 0.15.7
2
9
 
3
10
  * Support workflow on aws tokyo #94
@@ -74,6 +74,7 @@ module Command
74
74
 
75
75
  rows = []
76
76
  jobs.each {|job|
77
+ job.auto_update_status = false
77
78
  start = job.start_at
78
79
  elapsed = Command.humanize_elapsed_time(start, job.end_at)
79
80
  cpu_time = Command.humanize_time(job.cpu_time, true)
@@ -243,6 +243,7 @@ module List
243
243
  add_list 'table:tail', %w[db table], 'Get recently imported logs', ['table:tail example_db table1', 'table:tail example_db table1 -n 30']
244
244
  add_list 'table:partial_delete', %w[db table], 'Delete logs from the table within the specified time range', ['table:partial_delete example_db table1 --from 1341000000 --to 1341003600']
245
245
  add_list 'table:expire', %w[db table expire_days], 'Expire data in table after specified number of days. Set to 0 to disable the expiration.', ['table:expire example_db table1 30']
246
+ add_list 'table:update', %w[db table], 'Update table options', ['table:update example_db table1 --include-v false']
246
247
 
247
248
  add_list 'bulk_import:list', %w[], 'List bulk import sessions', ['bulk_import:list']
248
249
  add_list 'bulk_import:show', %w[name], 'Show list of uploaded parts', ['bulk_import:show']
@@ -256,7 +256,7 @@ module Command
256
256
  client = get_client
257
257
 
258
258
  begin
259
- history = client.history(name, skip, skip+max-1)
259
+ history = client.history(name, skip, skip+max)
260
260
  rescue NotFoundError
261
261
  cmd_debug_error $!
262
262
  $stderr.puts "Schedule '#{name}' does not exist."
@@ -15,6 +15,7 @@ module Command
15
15
  KEY_NUM_LIMIT = 512
16
16
 
17
17
  def table_create(op)
18
+ params = {}
18
19
  type = nil
19
20
 
20
21
  op.on('-T', '--type TYPE', 'set table type (log)') {|s|
@@ -23,6 +24,15 @@ module Command
23
24
  end
24
25
  type = s.to_sym
25
26
  }
27
+ op.on('--expire-days DAYS', Integer, 'set table expire days') do |v|
28
+ if v < 0
29
+ $stderr.puts "Table expiration days must be greater or equal to 0."
30
+ return
31
+ end
32
+ params[:expire_days] = v
33
+ end
34
+ op.on('--include-v BOOLEAN', TrueClass, 'set include_v flag') {|v| params[:include_v] = v}
35
+ op.on('--detect-schema BOOLEAN', TrueClass, 'set detect schema flag') {|v| params[:detect_schema] = v}
26
36
  db_name, table_name = op.cmd_parse
27
37
 
28
38
  API.validate_table_name(table_name)
@@ -36,7 +46,7 @@ module Command
36
46
  client = get_client
37
47
 
38
48
  begin
39
- client.create_log_table(db_name, table_name)
49
+ client.create_log_table(db_name, table_name, params)
40
50
  rescue NotFoundError
41
51
  cmd_debug_error $!
42
52
  $stderr.puts "Database '#{db_name}' does not exist."
@@ -218,6 +228,10 @@ module Command
218
228
  end
219
229
 
220
230
  def table_show(op)
231
+ verbose = nil
232
+ op.on('-v', 'show more attributes', TrueClass) {|b|
233
+ verbose = b
234
+ }
221
235
  db_name, table_name = op.cmd_parse
222
236
 
223
237
  client = get_client
@@ -227,7 +241,10 @@ module Command
227
241
  $stdout.puts "Name : #{table.db_name}.#{table.name}"
228
242
  $stdout.puts "Type : #{table.type}"
229
243
  $stdout.puts "Count : #{table.count}"
230
- # p table.methods.each {|m| $stdout.puts m}
244
+ if verbose
245
+ $stdout.puts "Expire Days : #{table.expire_days}"
246
+ $stdout.puts "Include v : #{table.include_v}"
247
+ end
231
248
  $stdout.puts "Schema : ("
232
249
  table.schema.fields.each {|f|
233
250
  $stdout.puts " #{f.name}:#{f.type}"
@@ -336,6 +353,25 @@ module Command
336
353
  end
337
354
  end
338
355
 
356
+ def table_update(op)
357
+ params = {}
358
+ op.on('--expire-days DAYS', Integer, 'set table expire days') do |v|
359
+ if v < 0
360
+ $stderr.puts "Table expiration days must be greater or equal to 0."
361
+ return
362
+ end
363
+ params[:expire_days] = v
364
+ end
365
+ op.on('--include-v BOOLEAN', TrueClass, 'set include_v flag') {|v| params[:include_v] = v}
366
+ op.on('--detect-schema BOOLEAN', TrueClass, 'set detect schema flag') {|v| params[:detect_schema] = v}
367
+ db_name, table_name = op.cmd_parse
368
+
369
+ client = get_client
370
+ res = client.update_table(db_name, table_name, params)
371
+
372
+ $stdout.puts res.inspect
373
+ end
374
+
339
375
  def table_expire(op)
340
376
  db_name, table_name, expire_days = op.cmd_parse
341
377
 
@@ -42,6 +42,7 @@ module TreasureData
42
42
  "secrets.td.apikey = #{apikey}"
43
43
  ].join($/) + $/)
44
44
  cmd << '-Dio.digdag.standards.td.secrets.enabled=false'
45
+ cmd << "-Dconfig.td.default_endpoint=#{Config.endpoint_domain}"
45
46
  else
46
47
  # Use the digdag td.conf plugin to configure wf api and apikey.
47
48
  env['TREASURE_DATA_CONFIG_PATH'] = Config.path
data/lib/td/config.rb CHANGED
@@ -152,6 +152,10 @@ class Config
152
152
  @@endpoint = endpoint
153
153
  end
154
154
 
155
+ def self.endpoint_domain
156
+ (self.endpoint || 'api.treasuredata.com').sub(%r[https?://], '')
157
+ end
158
+
155
159
  def self.cl_endpoint
156
160
  @@cl_endpoint
157
161
  end
@@ -161,13 +165,17 @@ class Config
161
165
  end
162
166
 
163
167
  def self.workflow_endpoint
164
- case self.endpoint.to_s.sub(%r[https?://], '')
165
- when '', 'api.treasuredata.com'
168
+ case self.endpoint_domain
169
+ when 'api.treasuredata.com'
166
170
  'https://api-workflow.treasuredata.com'
171
+ when /\Aapi-([^.]*).connect.treasuredata.com\z/
172
+ "https://api-workflow-#{$1}.connect.treasuredata.com"
167
173
  when 'api-staging.treasuredata.com'
168
174
  'https://api-staging-workflow.treasuredata.com'
169
175
  when 'api.treasuredata.co.jp'
170
176
  'https://api-workflow.treasuredata.co.jp'
177
+ when /\Aapi-([^.]*).connect.treasuredata.co.jp\z/
178
+ "https://api-workflow-#{$1}.connect.treasuredata.co.jp"
171
179
  when 'api-staging.treasuredata.co.jp'
172
180
  'https://api-staging-workflow.treasuredata.co.jp'
173
181
  else
data/lib/td/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module TreasureData
2
- TOOLBELT_VERSION = '0.15.7'
2
+ TOOLBELT_VERSION = '0.15.8'
3
3
  end
@@ -348,46 +348,39 @@ text
348
348
 
349
349
  let(:job_id) { "12345" }
350
350
 
351
- let :job_class do
352
- Struct.new(:job_id,
353
- :status,
354
- :type,
355
- :db_name,
356
- :priority,
357
- :retry_limit,
358
- :result_url,
359
- :query,
360
- :start_at,
361
- :end_at,
362
- :cpu_time,
363
- :result_size,
364
- :duration
365
- )
366
- end
367
-
368
351
  let :start_at do
369
352
  Time.now
370
353
  end
371
354
 
355
+ let :client do
356
+ double('client')
357
+ end
358
+
372
359
  let :jobs do
373
- [job_class.new(job_id,
374
- nil,
360
+ [TreasureData::Job.new(client,
361
+ job_id,
375
362
  :hive,
376
- "db_name",
377
- 1,
378
- 1,
379
- "test_url",
380
363
  "test_qury",
381
- start_at,
382
- start_at + 10,
364
+ nil,
365
+ nil,
366
+ nil,
367
+ start_at.iso8601,
368
+ (start_at + 10).iso8601,
383
369
  1,
384
370
  3,
385
- 100
371
+ nil,
372
+ "test_url",
373
+ nil,
374
+ 1,
375
+ 1,
376
+ nil,
377
+ "db_name",
378
+ 100,
379
+ 1,
386
380
  )] * 3
387
381
  end
388
382
 
389
383
  before do
390
- client = Object.new
391
384
  allow(client).to receive(:jobs).and_return(jobs)
392
385
  allow(command).to receive(:get_client).and_return(client)
393
386
  end
@@ -180,6 +180,124 @@ module TreasureData::Command
180
180
  end
181
181
  end
182
182
 
183
+ describe '#table_create' do
184
+ let(:db_name) { 'database' }
185
+ let(:table_name) { 'table1' }
186
+ let(:client) { double('client') }
187
+ let(:command) { Class.new { include TreasureData::Command }.new }
188
+
189
+ before do
190
+ allow(command).to receive(:get_client) { client }
191
+ end
192
+
193
+ context 'normal' do
194
+ let(:option) {
195
+ List::CommandParser.new('table:create', %w(db_name table_name), [], false, [db_name, table_name], false)
196
+ }
197
+
198
+ it 'create table' do
199
+ expect(client).to receive(:create_log_table).with(db_name, table_name, {})
200
+ command.table_create(option)
201
+ end
202
+ end
203
+
204
+ context 'with include_v' do
205
+ let(:option) {
206
+ List::CommandParser.new('table:create', %w(db_name table_name), [], false, [db_name, table_name, '--include-v'], false)
207
+ }
208
+
209
+ it 'raises Error' do
210
+ expect{ command.table_create(option) }.to raise_error(SystemExit)
211
+ end
212
+ end
213
+
214
+ context 'with include_v=true' do
215
+ let(:option) {
216
+ List::CommandParser.new('table:create', %w(db_name table_name), [], false, [db_name, table_name, '--include-v=true'], false)
217
+ }
218
+
219
+ it 'create table' do
220
+ expect(client).to receive(:create_log_table).with(db_name, table_name, {include_v: true})
221
+ expect{ command.table_create(option) }.not_to raise_error
222
+ end
223
+ end
224
+
225
+ context 'with include_v=false' do
226
+ let(:option) {
227
+ List::CommandParser.new('table:create', %w(db_name table_name), [], false, [db_name, table_name, '--include-v=false'], false)
228
+ }
229
+
230
+ it 'create table' do
231
+ expect(client).to receive(:create_log_table).with(db_name, table_name, {include_v: false})
232
+ expect{ command.table_create(option) }.not_to raise_error
233
+ end
234
+ end
235
+
236
+ context 'with detect_schema' do
237
+ let(:option) {
238
+ List::CommandParser.new('table:create', %w(db_name table_name), [], false, [db_name, table_name, '--detect-schema'], false)
239
+ }
240
+
241
+ it 'raises Error' do
242
+ expect{ command.table_create(option) }.to raise_error(SystemExit)
243
+ end
244
+ end
245
+
246
+ context 'with detect_schema=true' do
247
+ let(:option) {
248
+ List::CommandParser.new('table:create', %w(db_name table_name), [], false, [db_name, table_name, '--detect-schema=true'], false)
249
+ }
250
+
251
+ it 'create table' do
252
+ expect(client).to receive(:create_log_table).with(db_name, table_name, {detect_schema: true})
253
+ expect{ command.table_create(option) }.not_to raise_error
254
+ end
255
+ end
256
+
257
+ context 'with detect_schema=false' do
258
+ let(:option) {
259
+ List::CommandParser.new('table:create', %w(db_name table_name), [], false, [db_name, table_name, '--detect-schema=false'], false)
260
+ }
261
+
262
+ it 'create table' do
263
+ expect(client).to receive(:create_log_table).with(db_name, table_name, {detect_schema: false})
264
+ expect{ command.table_create(option) }.not_to raise_error
265
+ end
266
+ end
267
+
268
+ context 'with expire_days' do
269
+ let(:option) {
270
+ List::CommandParser.new('table:create', %w(db_name table_name), [], false, [db_name, table_name, '--expire-days'], false)
271
+ }
272
+
273
+ it 'raises Error' do
274
+ expect{ command.table_create(option) }.to raise_error(SystemExit)
275
+ end
276
+ end
277
+
278
+ context 'with expire_days=0' do
279
+ let(:option) {
280
+ List::CommandParser.new('table:create', %w(db_name table_name), [], false, [db_name, table_name, '--expire-days=0'], false)
281
+ }
282
+
283
+ it 'create table' do
284
+ expect(client).to receive(:create_log_table).with(db_name, table_name, {expire_days: 0})
285
+ expect{ command.table_create(option) }.not_to raise_error
286
+ end
287
+ end
288
+
289
+ context 'with expire_days=365' do
290
+ let(:option) {
291
+ List::CommandParser.new('table:create', %w(db_name table_name), [], false, [db_name, table_name, '--expire-days=365'], false)
292
+ }
293
+
294
+ it 'create table' do
295
+ expect(client).to receive(:create_log_table).with(db_name, table_name, {expire_days: 365})
296
+ expect{ command.table_create(option) }.not_to raise_error
297
+ end
298
+ end
299
+ end
300
+
183
301
  describe '#table_import' do
184
302
  let(:db_name) { 'database' }
185
303
  let(:table_name) { 'table' }
@@ -19,10 +19,18 @@ describe TreasureData::Config do
19
19
  it { is_expected.to eq 'https://api-workflow.treasuredata.com' }
20
20
  end
21
21
  end
22
+ context 'api-hoge.connect.treasuredata.com' do
23
+ let(:api_endpoint){ 'api-hoge.connect.treasuredata.com' }
24
+ it { is_expected.to eq 'https://api-workflow-hoge.connect.treasuredata.com' }
25
+ end
22
26
  context 'api.treasuredata.co.jp' do
23
27
  let(:api_endpoint){ 'api.treasuredata.co.jp' }
24
28
  it { is_expected.to eq 'https://api-workflow.treasuredata.co.jp' }
25
29
  end
30
+ context 'api-hoge.connect.treasuredata.co.jp' do
31
+ let(:api_endpoint){ 'api-hoge.connect.treasuredata.co.jp' }
32
+ it { is_expected.to eq 'https://api-workflow-hoge.connect.treasuredata.co.jp' }
33
+ end
26
34
  context 'api-staging.treasuredata.com' do
27
35
  let(:api_endpoint){ 'api-staging.treasuredata.com' }
28
36
  it { is_expected.to eq 'https://api-staging-workflow.treasuredata.com' }
data/td.gemspec CHANGED
@@ -21,7 +21,7 @@ Gem::Specification.new do |gem|
21
21
  gem.add_dependency "yajl-ruby", "~> 1.1"
22
22
  gem.add_dependency "hirb", ">= 0.4.5"
23
23
  gem.add_dependency "parallel", "~> 1.8"
24
- gem.add_dependency "td-client", ">= 1.0.4", "< 2"
24
+ gem.add_dependency "td-client", ">= 1.0.5", "< 2"
25
25
  gem.add_dependency "td-logger", ">= 0.3.21", "< 2"
26
26
  gem.add_dependency "rubyzip", ">= 1.2.1"
27
27
  gem.add_dependency "zip-zip", "~> 0.3"
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: td
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.15.7
4
+ version: 0.15.8
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: 2017-10-24 00:00:00.000000000 Z
11
+ date: 2018-01-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: msgpack
@@ -72,7 +72,7 @@ dependencies:
72
72
  requirements:
73
73
  - - ">="
74
74
  - !ruby/object:Gem::Version
75
- version: 1.0.4
75
+ version: 1.0.5
76
76
  - - "<"
77
77
  - !ruby/object:Gem::Version
78
78
  version: '2'
@@ -82,7 +82,7 @@ dependencies:
82
82
  requirements:
83
83
  - - ">="
84
84
  - !ruby/object:Gem::Version
85
- version: 1.0.4
85
+ version: 1.0.5
86
86
  - - "<"
87
87
  - !ruby/object:Gem::Version
88
88
  version: '2'