bricolage 5.12.3 → 5.12.4

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: 247e0b7b78e35324997d2ae53ddb4b346817c6f5
4
- data.tar.gz: 3d3e8a97e0802a507fa71c6117d5626854cc77ff
3
+ metadata.gz: f1936717e92dd5c0ceab713deb5f4ece78b91f49
4
+ data.tar.gz: 16721287ca7a2eb341796c06e8b21dcf57f50809
5
5
  SHA512:
6
- metadata.gz: 2aecb3e9be927e1914ad12ea86b438c6ba2e5d876368e4ea0befdaf69f640be5e92e298b117554b1681250d9dc1fae38c66fa6282cfd9756dbb4760368bc0b6b
7
- data.tar.gz: 510d226a01d49707bed15859bf6d1593efe6a3b4058089e4ba693824b6bef3410852f0bcabd7a162657c463b1293da92a9185c128c2f802ef8fee0832b6f6fa9
6
+ metadata.gz: cac5b19704f17a36b208cdb8e557659bf1d76a9b24c5a8ad9d06ca5e50adafa4b89a994aa04d751776d9ca680d2e6c04c754641440309055b7b58e991c85782b
7
+ data.tar.gz: 2458de15c20a2439ea130919ab1245a907557c971d6c2e150cd9ed83c4527359f98ff98a2933b0e04575be4f5a311c12f602ec8b88a7ad7a6d1a412d4c3ce21e
data/jobclass/create.rb CHANGED
@@ -4,6 +4,7 @@ JobClass.define('create') {
4
4
  params.add DestTableParam.new
5
5
  params.add OptionalBoolParam.new('drop', 'DROP table before CREATE.')
6
6
  params.add OptionalBoolParam.new('analyze', 'ANALYZE table after SQL is executed.')
7
+ params.add KeyValuePairsParam.new('grant', 'KEY:VALUE', 'GRANT table after SQL is executed. (required keys: privilege, to)')
7
8
  params.add DataSourceParam.new('sql')
8
9
  }
9
10
 
@@ -16,6 +17,7 @@ JobClass.define('create') {
16
17
  task.drop_force_if params['drop']
17
18
  task.exec params['table-def']
18
19
  task.analyze_if params['analyze']
20
+ task.grant_if params['grant'], params['dest-table']
19
21
  }
20
22
  }
21
23
  }
@@ -0,0 +1,22 @@
1
+ JobClass.define('createview') {
2
+ parameters {|params|
3
+ params.add SQLFileParam.new('sql-file', 'PATH', 'CREATE VIEW file.')
4
+ params.add DestTableParam.new
5
+ params.add SrcTableParam.new
6
+ params.add OptionalBoolParam.new('drop', 'DROP table before CREATE.')
7
+ params.add KeyValuePairsParam.new('grant', 'KEY:VALUE', 'GRANT table after SQL is executed. (required keys: privilege, to)')
8
+ params.add DataSourceParam.new('sql')
9
+ }
10
+
11
+ declarations {|params|
12
+ params['sql-file'].declarations
13
+ }
14
+
15
+ script {|params, script|
16
+ script.task(params['data-source']) {|task|
17
+ task.drop_view_force_if params['drop']
18
+ task.exec params['sql-file']
19
+ task.grant_if params['grant'], params['dest-table']
20
+ }
21
+ }
22
+ }
@@ -27,7 +27,7 @@ JobClass.define('my-migrate') {
27
27
  params.add OptionalBoolParam.new('analyze', 'ANALYZE table after SQL is executed.', default: true)
28
28
  params.add OptionalBoolParam.new('vacuum', 'VACUUM table after SQL is executed.')
29
29
  params.add OptionalBoolParam.new('vacuum-sort', 'VACUUM SORT table after SQL is executed.')
30
- params.add KeyValuePairsParam.new('grant', 'KEY:VALUE', 'GRANT table after SQL is executed.')
30
+ params.add KeyValuePairsParam.new('grant', 'KEY:VALUE', 'GRANT table after SQL is executed. (required keys: privilege, to)')
31
31
 
32
32
  # All
33
33
  params.add OptionalBoolParam.new('export', 'Runs EXPORT task.')
@@ -7,7 +7,7 @@ JobClass.define('rebuild-drop') {
7
7
  params.add OptionalBoolParam.new('analyze', 'ANALYZE table after SQL is executed.', default: true)
8
8
  params.add OptionalBoolParam.new('vacuum', 'VACUUM table after SQL is executed.')
9
9
  params.add OptionalBoolParam.new('vacuum-sort', 'VACUUM SORT table after SQL is executed.')
10
- params.add KeyValuePairsParam.new('grant', 'KEY:VALUE', 'GRANT table after SQL is executed. (required keys: on, to)')
10
+ params.add KeyValuePairsParam.new('grant', 'KEY:VALUE', 'GRANT table after SQL is executed. (required keys: privilege, to)')
11
11
  params.add DataSourceParam.new('sql')
12
12
  }
13
13
 
@@ -7,7 +7,7 @@ JobClass.define('rebuild-rename') {
7
7
  params.add OptionalBoolParam.new('analyze', 'ANALYZE table after SQL is executed.', default: true)
8
8
  params.add OptionalBoolParam.new('vacuum', 'VACUUM table after SQL is executed.')
9
9
  params.add OptionalBoolParam.new('vacuum-sort', 'VACUUM SORT table after SQL is executed.')
10
- params.add KeyValuePairsParam.new('grant', 'KEY:VALUE', 'GRANT table after SQL is executed.')
10
+ params.add KeyValuePairsParam.new('grant', 'KEY:VALUE', 'GRANT table after SQL is executed. (required keys: privilege, to)')
11
11
  params.add DataSourceParam.new('sql')
12
12
  }
13
13
 
data/jobclass/sql.rb CHANGED
@@ -7,6 +7,7 @@ JobClass.define('sql') {
7
7
  params.add OptionalBoolParam.new('analyze', 'ANALYZE table after SQL is executed.')
8
8
  params.add OptionalBoolParam.new('vacuum', 'VACUUM table after SQL is executed.')
9
9
  params.add OptionalBoolParam.new('vacuum-sort', 'VACUUM SORT table after SQL is executed.')
10
+ params.add KeyValuePairsParam.new('grant', 'KEY:VALUE', 'GRANT table after SQL is executed. (required keys: privilege, to)')
10
11
  params.add DataSourceParam.new('sql')
11
12
  }
12
13
 
@@ -24,6 +25,7 @@ JobClass.define('sql') {
24
25
  task.exec params['sql-file']
25
26
  task.vacuum_if params['vacuum'], params['vacuum-sort']
26
27
  task.analyze_if params['analyze']
28
+ task.grant_if params['grant'], params['dest-table']
27
29
  }
28
30
  }
29
31
  }
@@ -4,6 +4,7 @@ require 'json'
4
4
  require 'csv'
5
5
  require 'stringio'
6
6
  require 'open3'
7
+ require 'etc'
7
8
 
8
9
  module Bricolage
9
10
 
@@ -66,7 +67,7 @@ module Bricolage
66
67
  end
67
68
 
68
69
  class MySQLTask < DataSourceTask
69
- def export(stmt, path: nil, format: nil, override: false, gzip: false, sqldump: sqldump)
70
+ def export(stmt, path: nil, format: nil, override: false, gzip: false, sqldump: false)
70
71
  add Export.new(stmt, path: path, format: format, override: override, gzip: gzip, sqldump: sqldump)
71
72
  end
72
73
 
@@ -118,7 +119,7 @@ module Bricolage
118
119
  end
119
120
 
120
121
  def sqldump_available?
121
- sqldump_path.executable?
122
+ sqldump_real_path.executable?
122
123
  end
123
124
 
124
125
  def sqldump_path
@@ -130,7 +131,7 @@ module Bricolage
130
131
  end
131
132
 
132
133
  def platform_name
133
- @platform_name ||= `uname -s`
134
+ @platform_name ||= Etc.uname[:sysname]
134
135
  end
135
136
 
136
137
  def sqldump_usable?
@@ -232,18 +232,30 @@ module Bricolage
232
232
  drop '${dest_table}' if enabled
233
233
  end
234
234
 
235
- def drop_force(target_table)
235
+ def drop_obj_force(type, name)
236
236
  exec SQLStatement.for_string(
237
237
  "\\set ON_ERROR_STOP false\n" +
238
- "drop table #{target_table} cascade;\n" +
238
+ "drop #{type} #{name} cascade;\n" +
239
239
  "\\set ON_ERROR_STOP true\n"
240
240
  )
241
241
  end
242
242
 
243
+ def drop_force(target_table)
244
+ drop_obj_force('table', target_table)
245
+ end
246
+
247
+ def drop_view_force(target_view)
248
+ drop_obj_force('view', target_view)
249
+ end
250
+
243
251
  def drop_force_if(enabled)
244
252
  drop_force('${dest_table}') if enabled
245
253
  end
246
254
 
255
+ def drop_view_force_if(enabled)
256
+ drop_view_force('${dest_table}') if enabled
257
+ end
258
+
247
259
  def truncate_if(enabled, target = '${dest_table}')
248
260
  exec SQLStatement.for_string("truncate #{target};") if enabled
249
261
  end
@@ -310,6 +322,7 @@ module Bricolage
310
322
  unless src_ds.redshift_loader_source?
311
323
  raise ParameterError, "input data source does not support redshift as bulk loading source: #{src_ds.name}"
312
324
  end
325
+ provide_default_load_options opts, src_ds
313
326
  buf = StringIO.new
314
327
  buf.puts "copy #{dest_table}"
315
328
  buf.puts "from '#{src_ds.url(src_path)}'"
@@ -322,6 +335,12 @@ module Bricolage
322
335
  buf.string
323
336
  end
324
337
 
338
+ def provide_default_load_options(opts, src_ds)
339
+ if src_ds.encrypted? and not opts.key?('encrypted')
340
+ opts['encrypted'] = true
341
+ end
342
+ end
343
+
325
344
  def format_option(fmt, src_ds, jsonpath)
326
345
  case fmt
327
346
  when 'tsv'
@@ -420,10 +439,25 @@ module Bricolage
420
439
  @opts = opts
421
440
  end
422
441
 
442
+ def key?(name)
443
+ n = name.to_s
444
+ @opts.any? {|opt| opt.name == n }
445
+ end
446
+
423
447
  def each(&block)
424
448
  @opts.each(&block)
425
449
  end
426
450
 
451
+ def []=(name, value)
452
+ n = name.to_s
453
+ delete n
454
+ @opts.push Option.new(n, value)
455
+ end
456
+
457
+ def delete(name)
458
+ @opts.reject! {|opt| opt.name == name }
459
+ end
460
+
427
461
  def merge(pairs)
428
462
  h = {}
429
463
  @opts.each do |opt|
@@ -465,6 +499,8 @@ module Bricolage
465
499
  "#{@name} '#{@value}'"
466
500
  when Integer # maxerror 10
467
501
  "#{@name} #{@value}"
502
+ when nil # (explicitly disable boolean options)
503
+ ''
468
504
  else
469
505
  raise ParameterError, "unsupported type of option value for #{@name}: #{@value.inspect}"
470
506
  end
@@ -10,13 +10,14 @@ module Bricolage
10
10
 
11
11
  def initialize(endpoint: 's3-ap-northeast-1.amazonaws.com',
12
12
  bucket: nil, prefix: nil,
13
- access_key_id: nil, secret_access_key: nil,
13
+ access_key_id: nil, secret_access_key: nil, master_symmetric_key: nil,
14
14
  s3cfg: nil)
15
15
  @endpoint = endpoint
16
16
  @bucket = bucket
17
17
  @prefix = (prefix && prefix.empty?) ? nil : prefix
18
18
  @access_key_id = access_key_id
19
19
  @secret_access_key = secret_access_key
20
+ @master_symmetric_key = master_symmetric_key
20
21
  @s3cfg = s3cfg
21
22
  @configurations = @s3cfg ? load_configurations(@s3cfg) : nil
22
23
  end
@@ -31,7 +32,11 @@ module Bricolage
31
32
 
32
33
  # For Redshift
33
34
  def credential_string
34
- "aws_access_key_id=#{access_key};aws_secret_access_key=#{secret_key}"
35
+ [
36
+ "aws_access_key_id=#{access_key}",
37
+ "aws_secret_access_key=#{secret_key}",
38
+ (@master_symmetric_key && "master_symmetric_key=#{@master_symmetric_key}")
39
+ ].compact.join(';')
35
40
  end
36
41
 
37
42
  def access_key
@@ -59,6 +64,10 @@ module Bricolage
59
64
  h
60
65
  end
61
66
 
67
+ def encrypted?
68
+ !!@master_symmetric_key
69
+ end
70
+
62
71
  #
63
72
  # Ruby Interface
64
73
  #
@@ -1,4 +1,4 @@
1
1
  module Bricolage
2
2
  APPLICATION_NAME = 'Bricolage'
3
- VERSION = '5.12.3'
3
+ VERSION = '5.12.4'
4
4
  end
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: ../..
3
3
  specs:
4
- bricolage (5.12.3)
4
+ bricolage (5.12.4)
5
5
  aws-sdk (< 2)
6
6
  mysql2
7
7
  pg
@@ -50,6 +50,7 @@ s3:
50
50
  s3cfg: <%= user_home_relative_path '.s3cfg' %>
51
51
  access_key_id: "AKIAI5R5BL2W73PR3FXQ"
52
52
  secret_access_key: "Mj9/cwWuruUO0qHsYFI2911G31PQaIj3+eJTBxyO"
53
+ #master_symmetric_key: "12345678901234567890123456789012"
53
54
 
54
55
  mysql:
55
56
  type: mysql
@@ -0,0 +1,9 @@
1
+ class: load
2
+ drop: true
3
+ table-def: search_backends.ct
4
+ dest-table: $test_schema.search_backends
5
+ src-file: /search_backends/search_backends.json.gz
6
+ format: json
7
+ options:
8
+ gzip: true
9
+ #encrypted: null
@@ -0,0 +1,11 @@
1
+ /*
2
+ class: createview
3
+ drop: true
4
+ dest-table: some_view
5
+ src-tables:
6
+ d: d
7
+ */
8
+
9
+ create view $dest_table as
10
+ select * from $d
11
+ ;
@@ -1,4 +1,5 @@
1
1
  defaults:
2
+ analyze: true
2
3
  grant:
3
4
  privilege: "select"
4
5
  to: "$test_group"
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bricolage
3
3
  version: !ruby/object:Gem::Version
4
- version: 5.12.3
4
+ version: 5.12.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Minero Aoki
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-11-16 00:00:00.000000000 Z
11
+ date: 2015-11-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: pg
@@ -106,6 +106,7 @@ files:
106
106
  - bin/bricolage
107
107
  - bin/bricolage-jobnet
108
108
  - jobclass/create.rb
109
+ - jobclass/createview.rb
109
110
  - jobclass/exec.rb
110
111
  - jobclass/insert-delta.rb
111
112
  - jobclass/insert.rb
@@ -180,6 +181,7 @@ files:
180
181
  - test/home/subsys/job5.job
181
182
  - test/home/subsys/job6.job
182
183
  - test/home/subsys/job7.job
184
+ - test/home/subsys/load.job
183
185
  - test/home/subsys/load_test.ct
184
186
  - test/home/subsys/load_test.job
185
187
  - test/home/subsys/migrate.job
@@ -191,6 +193,7 @@ files:
191
193
  - test/home/subsys/search_backends.ct
192
194
  - test/home/subsys/separated.job
193
195
  - test/home/subsys/separated.sql
196
+ - test/home/subsys/some_view-cv.sql.job
194
197
  - test/home/subsys/unified.jobnet
195
198
  - test/home/subsys/unified.sql.job
196
199
  - test/home/subsys/variable.yml