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 +4 -4
- data/README.md +6 -0
- data/jobclass/insert-delta.rb +1 -1
- data/jobclass/insert.rb +1 -1
- data/lib/bricolage/context.rb +2 -1
- data/lib/bricolage/job.rb +2 -1
- data/lib/bricolage/jobnetrunner.rb +3 -0
- data/lib/bricolage/parameters.rb +30 -0
- data/lib/bricolage/variables.rb +5 -0
- data/lib/bricolage/version.rb +1 -1
- data/test/home/Gemfile.lock +1 -1
- data/test/home/subsys/insert.sql.job +7 -0
- data/test/home/subsys/rebuild.sql.job +1 -0
- data/test/home/subsys/variable.yml +4 -0
- metadata +3 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a2a7116f2a283155f91b6b272454abf1515850ef
|
4
|
+
data.tar.gz: d6f816f16389853b0acb524deb11824bfb9ed366
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3c165aea2e6e48000218965f89f57889d17677e13a1e1894a958f4c615e20aea8da4672c4718b12a4a7e0df4acdc6b70865bad77a3dd19cfae7ef34f46906be5
|
7
|
+
data.tar.gz: 1c3845da421375c166485d502ca51172d877cfedefe6db8896fb65869a030dbb3e71d8a96ab20804e67d952920fbd6e89ae2efec2ee9bc2a559ede07fb52ac09
|
data/README.md
CHANGED
data/jobclass/insert-delta.rb
CHANGED
@@ -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')
|
data/lib/bricolage/context.rb
CHANGED
@@ -87,7 +87,8 @@ module Bricolage
|
|
87
87
|
end
|
88
88
|
|
89
89
|
def load_global_variables
|
90
|
-
|
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.
|
data/lib/bricolage/parameters.rb
CHANGED
@@ -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
|
data/lib/bricolage/variables.rb
CHANGED
data/lib/bricolage/version.rb
CHANGED
data/test/home/Gemfile.lock
CHANGED
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.
|
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
|