bricolage 5.11.0 → 5.12.0

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: 1ff4f8adcd84bf94e55cb1d285a3b5671210906e
4
- data.tar.gz: b1f3f08b9c0e74a5e6d469ba197a29d08b51551f
3
+ metadata.gz: a2a7116f2a283155f91b6b272454abf1515850ef
4
+ data.tar.gz: d6f816f16389853b0acb524deb11824bfb9ed366
5
5
  SHA512:
6
- metadata.gz: aec57849ed95f3c50bd0befdcaf66ddad3f6ab2aeb241e139f51e996a64e18ae63023e624a13f44daa9a5330d75d2928cc0df447f4ecae3c9055934b519647c5
7
- data.tar.gz: dab80eab00b0e147249fcf6f53a6a75314a0b2161991d46fc0ffe21cedbc29fae3a6e0f00c6d95c60f3ddc26a5438c7d93061ca132a3714d0192b02abc63c593
6
+ metadata.gz: 3c165aea2e6e48000218965f89f57889d17677e13a1e1894a958f4c615e20aea8da4672c4718b12a4a7e0df4acdc6b70865bad77a3dd19cfae7ef34f46906be5
7
+ data.tar.gz: 1c3845da421375c166485d502ca51172d877cfedefe6db8896fb65869a030dbb3e71d8a96ab20804e67d952920fbd6e89ae2efec2ee9bc2a559ede07fb52ac09
data/README.md CHANGED
@@ -13,6 +13,12 @@ MIT license.
13
13
  See LICENSES file for details.
14
14
 
15
15
 
16
+ Running Test
17
+ ------------
18
+
19
+ % rake test
20
+
21
+
16
22
  Author
17
23
  ------
18
24
 
@@ -4,7 +4,7 @@ JobClass.define('insert-delta') {
4
4
  params.add DestTableParam.new
5
5
  params.add SrcTableParam.new
6
6
  params.add StringParam.new('delete-cond', 'SQL_EXPR', 'DELETE condition.')
7
- params.add OptionalBoolParam.new('analyze', 'ANALYZE table after SQL is executed.')
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
10
  params.add DataSourceParam.new('sql')
data/jobclass/insert.rb CHANGED
@@ -6,7 +6,7 @@ JobClass.define('insert') {
6
6
  params.add SQLFileParam.new('table-def', 'PATH', 'Create table file.', optional: true)
7
7
  params.add OptionalBoolParam.new('drop', 'DROP table before CREATE.')
8
8
  params.add OptionalBoolParam.new('truncate', 'TRUNCATE table before SQL is executed.')
9
- params.add OptionalBoolParam.new('analyze', 'ANALYZE table after SQL is executed.')
9
+ params.add OptionalBoolParam.new('analyze', 'ANALYZE table after SQL is executed.', default: true)
10
10
  params.add OptionalBoolParam.new('vacuum', 'VACUUM table after SQL is executed.')
11
11
  params.add OptionalBoolParam.new('vacuum-sort', 'VACUUM SORT table after SQL is executed.')
12
12
  params.add DataSourceParam.new('sql')
@@ -87,7 +87,8 @@ module Bricolage
87
87
  end
88
88
 
89
89
  def load_global_variables
90
- vars_list = config_pathes(GLOBAL_VARIABLE_FILE).map {|path|
90
+ subsys_path = scoped? ? [@filesystem.relative(GLOBAL_VARIABLE_FILE)] : []
91
+ vars_list = (config_pathes(GLOBAL_VARIABLE_FILE) + subsys_path).map {|path|
91
92
  path.exist? ? load_variables(path) : nil
92
93
  }
93
94
  Variables.union(*vars_list.compact)
data/lib/bricolage/job.rb CHANGED
@@ -73,6 +73,7 @@ module Bricolage
73
73
  end
74
74
 
75
75
  def compile
76
+ param_vals_default = @param_decls.parse_default_values(@global_variables.get_force('defaults'))
76
77
  @job_class.invoke_parameters_filter(self)
77
78
 
78
79
  job_file_rest_vars = @param_vals ? @param_vals.variables : Variables.new
@@ -87,7 +88,7 @@ module Bricolage
87
88
  job_v_opt_vars
88
89
  # v High precedence
89
90
  )
90
- pvals = @param_decls.union_intermediate_values(*[@param_vals, @param_vals_opt].compact)
91
+ pvals = @param_decls.union_intermediate_values(*[param_vals_default, @param_vals, @param_vals_opt].compact)
91
92
  @params = pvals.resolve(@context, base_vars.resolve)
92
93
 
93
94
  # Then, expand SQL variables and check with declarations.
@@ -148,6 +148,9 @@ module Bricolage
148
148
  }
149
149
  end
150
150
 
151
+ public :puts
152
+ public :exit
153
+
151
154
  def usage_exit(msg, usage)
152
155
  print_error msg
153
156
  $stderr.puts usage
@@ -34,6 +34,11 @@ module Bricolage
34
34
  @decls.each_value(&block)
35
35
  end
36
36
 
37
+ def parse_default_values(values)
38
+ return IntermediateValues.empty(self) unless values
39
+ DefaultValuesHandler.new(self).parse(values)
40
+ end
41
+
37
42
  def parse_direct_values(values)
38
43
  DirectValueHandler.new(self).parse(values)
39
44
  end
@@ -49,6 +54,29 @@ module Bricolage
49
54
  end
50
55
  end
51
56
 
57
+ # Handles default values given by variable.yml (global or subsystem variables)
58
+ # Declarations + values -> IntermediateValues
59
+ class DefaultValuesHandler
60
+ def initialize(decls)
61
+ @decls = decls
62
+ end
63
+
64
+ def parse(values)
65
+ unless values.kind_of?(Hash)
66
+ raise ParameterError, "invalid type for 'defaults' global variable: #{values.class}"
67
+ end
68
+ parsed_values = {}
69
+ values.each do |name, value|
70
+ decl = @decls[name]
71
+ next unless decl # ignore undeclared option
72
+ val = decl.parse_value(value)
73
+ # nil means really nil for default values.
74
+ parsed_values[name] = val
75
+ end
76
+ IntermediateValues.new(@decls, parsed_values, Variables.new)
77
+ end
78
+ end
79
+
52
80
  # Handles *.job file values.
53
81
  # Declarations + values -> IntermediateValues
54
82
  class DirectValueHandler
@@ -626,6 +654,8 @@ module Bricolage
626
654
  when String # FIXME: should be removed after changing all load options
627
655
  raise ParameterError, "bad type for parameter #{name}: #{h.class}" unless @value_handler
628
656
  h.strip.empty? ? nil : h
657
+ when nil, false # disables option explicitly
658
+ {}
629
659
  else
630
660
  raise ParameterError, "bad type for parameter #{name}: #{h.class}"
631
661
  end
@@ -38,6 +38,11 @@ module Bricolage
38
38
  var.value
39
39
  end
40
40
 
41
+ def get_force(name)
42
+ var = @vars[name]
43
+ var ? var.value : nil
44
+ end
45
+
41
46
  def []=(name, value)
42
47
  add Variable.new(name, value)
43
48
  end
@@ -1,4 +1,4 @@
1
1
  module Bricolage
2
2
  APPLICATION_NAME = 'Bricolage'
3
- VERSION = '5.11.0'
3
+ VERSION = '5.12.0'
4
4
  end
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: ../..
3
3
  specs:
4
- bricolage (5.11.0)
4
+ bricolage (5.12.0)
5
5
  aws-sdk (< 2)
6
6
  mysql2
7
7
  pg
@@ -0,0 +1,7 @@
1
+ /*
2
+ class: insert
3
+ dest-table: d
4
+ src-tables: {s: s}
5
+ */
6
+
7
+ insert into $dest_table select * from $s;
@@ -6,6 +6,7 @@
6
6
  s: s
7
7
  analyze: true
8
8
  vacuum-sort: true
9
+ #grant: false
9
10
  */
10
11
 
11
12
  insert into $dest_table
@@ -0,0 +1,4 @@
1
+ defaults:
2
+ grant:
3
+ privilege: "select"
4
+ to: "$test_group"
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bricolage
3
3
  version: !ruby/object:Gem::Version
4
- version: 5.11.0
4
+ version: 5.12.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Minero Aoki
@@ -172,6 +172,7 @@ files:
172
172
  - test/home/put.sh
173
173
  - test/home/revert.sh
174
174
  - test/home/subsys/d.ct
175
+ - test/home/subsys/insert.sql.job
175
176
  - test/home/subsys/job1.job
176
177
  - test/home/subsys/job2.job
177
178
  - test/home/subsys/job3.job
@@ -191,6 +192,7 @@ files:
191
192
  - test/home/subsys/separated.sql
192
193
  - test/home/subsys/unified.jobnet
193
194
  - test/home/subsys/unified.sql.job
195
+ - test/home/subsys/variable.yml
194
196
  - test/test_c_streaming_load.rb
195
197
  - test/test_filesystem.rb
196
198
  - test/test_parameters.rb