masamune 0.13.1 → 0.13.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/masamune/transform/bulk_upsert.psql.erb +1 -1
- data/lib/masamune/transform/define_table.psql.erb +1 -1
- data/lib/masamune/transform/insert_reference_values.psql.erb +1 -1
- data/lib/masamune/transform/replace_table.psql.erb +1 -1
- data/lib/masamune/transform/stage_dimension.psql.erb +1 -1
- data/lib/masamune/transform/stage_fact.rb +11 -2
- data/lib/masamune/version.rb +1 -1
- data/spec/masamune/transform/bulk_upsert.dimension_spec.rb +2 -2
- data/spec/masamune/transform/define_table.fact_spec.rb +1 -1
- data/spec/masamune/transform/define_table.table_spec.rb +5 -5
- data/spec/masamune/transform/insert_reference_values.dimension_spec.rb +2 -2
- data/spec/masamune/transform/insert_reference_values.fact_spec.rb +4 -4
- data/spec/masamune/transform/rollup_fact_spec.rb +3 -3
- data/spec/masamune/transform/stage_dimension_spec.rb +1 -1
- data/spec/masamune/transform/stage_fact_spec.rb +6 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8fa6da8799159be2bb3472751c15650fee02f59f
|
4
|
+
data.tar.gz: ea974ce24ad0a23c35b74c9d1c7088c7bbce01c3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2e7b57261f2885aab5bfdbd3d4fa6cfceddeda92dc5d6919d9526107e04da9f99774ca1186a32f11391ef8e4f287ea5c300c0f8f8c3d226f5be1d446ebcbb50f
|
7
|
+
data.tar.gz: 1fd79cfc1578985db4d2d64cfc84197f8071497cd351c875aa5b50930263e14a119f095307bea842ea50508ad79bce17acd967dbfba53d60a217c8fc188c1e28
|
@@ -113,7 +113,7 @@ WHERE NOT EXISTS (SELECT 1 FROM <%= target.name %> WHERE <%= row.insert_constrai
|
|
113
113
|
<%- end -%>
|
114
114
|
|
115
115
|
<%- if helper.perform_analyze? -%>
|
116
|
-
ANALYZE <%= target.name %>;
|
116
|
+
VACUUM FULL ANALYZE <%= target.name %>;
|
117
117
|
<%- end -%>
|
118
118
|
|
119
119
|
<%- if helper.define_functions? -%>
|
@@ -73,6 +73,7 @@ module Masamune::Transform
|
|
73
73
|
next if column.degenerate?
|
74
74
|
dependencies[reference_name] ||= []
|
75
75
|
cross_references = cross_references(column)
|
76
|
+
|
76
77
|
coalesce_values = []
|
77
78
|
|
78
79
|
if cross_references.any?
|
@@ -80,8 +81,13 @@ module Masamune::Transform
|
|
80
81
|
coalesce_values << cross_references.map { |reference, column| column.qualified_name(reference.label) }
|
81
82
|
end
|
82
83
|
|
83
|
-
|
84
|
-
|
84
|
+
column.reference.auto_surrogate_keys.each do |auto_surrogate_key|
|
85
|
+
next unless auto_surrogate_key.default
|
86
|
+
conditions[reference_name] << "#{auto_surrogate_key.qualified_name(reference.label)} = #{auto_surrogate_key.default}"
|
87
|
+
end if column.reference
|
88
|
+
|
89
|
+
if column.reference && !column.reference.default.nil? && column.adjacent.natural_key
|
90
|
+
coalesce_values << column.reference.default(column.adjacent)
|
85
91
|
elsif column.adjacent && !column.adjacent.default.nil?
|
86
92
|
coalesce_values << column.adjacent.sql_value(column.adjacent.default)
|
87
93
|
end
|
@@ -90,11 +96,14 @@ module Masamune::Transform
|
|
90
96
|
"#{column.foreign_key_name} = COALESCE(#{column.qualified_name}, #{coalesce_values.join(', ')})" :
|
91
97
|
"#{column.foreign_key_name} = #{column.qualified_name}")
|
92
98
|
end
|
99
|
+
|
93
100
|
if reference.type == :two || reference.type == :four
|
94
101
|
join_key_a = "TO_TIMESTAMP(#{source.time_key.qualified_name}) BETWEEN #{reference.start_key.qualified_name(reference.label)} AND COALESCE(#{reference.end_key.qualified_name(reference.label)}, 'INFINITY')"
|
95
102
|
join_key_b = "TO_TIMESTAMP(#{source.time_key.qualified_name}) < #{reference.start_key.qualified_name(reference.label)} AND #{reference.version_key.qualified_name(reference.label)} = 1"
|
96
103
|
conditions[reference_name] << "((#{join_key_a}) OR (#{join_key_b}))"
|
97
104
|
end
|
105
|
+
|
106
|
+
conditions[reference_name].uniq!
|
98
107
|
end
|
99
108
|
conditions.slice(*dependencies.tsort)
|
100
109
|
end
|
data/lib/masamune/version.rb
CHANGED
@@ -127,7 +127,7 @@ describe Masamune::Transform::BulkUpsert do
|
|
127
127
|
user_dimension.start_at IS NULL
|
128
128
|
;
|
129
129
|
|
130
|
-
ANALYZE user_dimension;
|
130
|
+
VACUUM FULL ANALYZE user_dimension;
|
131
131
|
|
132
132
|
COMMIT;
|
133
133
|
EOS
|
@@ -193,7 +193,7 @@ describe Masamune::Transform::BulkUpsert do
|
|
193
193
|
user_dimension_ledger.start_at IS NULL
|
194
194
|
;
|
195
195
|
|
196
|
-
ANALYZE user_dimension_ledger;
|
196
|
+
VACUUM FULL ANALYZE user_dimension_ledger;
|
197
197
|
|
198
198
|
COMMIT;
|
199
199
|
EOS
|
@@ -198,7 +198,7 @@ describe Masamune::Transform::DefineTable do
|
|
198
198
|
CREATE INDEX visits_file_fact_stage_0fe2101_index ON visits_file_fact_stage (user_agent_type_version, time_key);
|
199
199
|
CREATE INDEX visits_file_fact_stage_b0abfed_index ON visits_file_fact_stage (user_dimension_user_id, time_key);
|
200
200
|
|
201
|
-
ANALYZE visits_file_fact_stage;
|
201
|
+
VACUUM FULL ANALYZE visits_file_fact_stage;
|
202
202
|
EOS
|
203
203
|
end
|
204
204
|
|
@@ -474,7 +474,7 @@ describe Masamune::Transform::DefineTable do
|
|
474
474
|
SELECT 'active'
|
475
475
|
WHERE NOT EXISTS (SELECT 1 FROM user_table WHERE name = 'active');
|
476
476
|
|
477
|
-
ANALYZE user_table;
|
477
|
+
VACUUM FULL ANALYZE user_table;
|
478
478
|
EOS
|
479
479
|
end
|
480
480
|
end
|
@@ -574,7 +574,7 @@ describe Masamune::Transform::DefineTable do
|
|
574
574
|
SELECT default_tenant_id(), -2
|
575
575
|
WHERE NOT EXISTS (SELECT 1 FROM user_table WHERE tenant_id = default_tenant_id() AND user_id = -2);
|
576
576
|
|
577
|
-
ANALYZE user_table;
|
577
|
+
VACUUM FULL ANALYZE user_table;
|
578
578
|
|
579
579
|
CREATE OR REPLACE FUNCTION default_user_table_user_id()
|
580
580
|
RETURNS INTEGER IMMUTABLE AS $$
|
@@ -902,7 +902,7 @@ describe Masamune::Transform::DefineTable do
|
|
902
902
|
ALTER TABLE user_table ADD CONSTRAINT user_table_3854361_key UNIQUE(tenant_id);
|
903
903
|
END IF; END $$;
|
904
904
|
|
905
|
-
ANALYZE user_table;
|
905
|
+
VACUUM FULL ANALYZE user_table;
|
906
906
|
EOS
|
907
907
|
end
|
908
908
|
end
|
@@ -937,7 +937,7 @@ describe Masamune::Transform::DefineTable do
|
|
937
937
|
CREATE INDEX user_table_e8701ad_index ON user_table (user_id);
|
938
938
|
END IF; END $$;
|
939
939
|
|
940
|
-
ANALYZE user_table;
|
940
|
+
VACUUM FULL ANALYZE user_table;
|
941
941
|
EOS
|
942
942
|
end
|
943
943
|
end
|
@@ -975,7 +975,7 @@ describe Masamune::Transform::DefineTable do
|
|
975
975
|
ALTER TABLE user_table ADD CONSTRAINT user_table_bd2027e_fkey FOREIGN KEY (user_account_state_table_id) REFERENCES user_account_state_table(id);
|
976
976
|
END IF; END $$;
|
977
977
|
|
978
|
-
ANALYZE user_table;
|
978
|
+
VACUUM FULL ANALYZE user_table;
|
979
979
|
EOS
|
980
980
|
end
|
981
981
|
end
|
@@ -74,7 +74,7 @@ describe Masamune::Transform::InsertReferenceValues do
|
|
74
74
|
department_type_department_id IS NOT NULL
|
75
75
|
;
|
76
76
|
|
77
|
-
ANALYZE department_type_stage;
|
77
|
+
VACUUM FULL ANALYZE department_type_stage;
|
78
78
|
|
79
79
|
BEGIN;
|
80
80
|
LOCK TABLE department_type IN EXCLUSIVE MODE;
|
@@ -96,7 +96,7 @@ describe Masamune::Transform::InsertReferenceValues do
|
|
96
96
|
department_type.department_id IS NULL
|
97
97
|
;
|
98
98
|
|
99
|
-
ANALYZE department_type;
|
99
|
+
VACUUM FULL ANALYZE department_type;
|
100
100
|
|
101
101
|
COMMIT;
|
102
102
|
EOS
|
@@ -91,7 +91,7 @@ describe Masamune::Transform::InsertReferenceValues do
|
|
91
91
|
user_agent_type_name IS NOT NULL
|
92
92
|
;
|
93
93
|
|
94
|
-
ANALYZE user_agent_type_stage;
|
94
|
+
VACUUM FULL ANALYZE user_agent_type_stage;
|
95
95
|
|
96
96
|
BEGIN;
|
97
97
|
LOCK TABLE user_agent_type IN EXCLUSIVE MODE;
|
@@ -113,7 +113,7 @@ describe Masamune::Transform::InsertReferenceValues do
|
|
113
113
|
user_agent_type.version IS NULL
|
114
114
|
;
|
115
115
|
|
116
|
-
ANALYZE user_agent_type;
|
116
|
+
VACUUM FULL ANALYZE user_agent_type;
|
117
117
|
|
118
118
|
COMMIT;
|
119
119
|
|
@@ -129,7 +129,7 @@ describe Masamune::Transform::InsertReferenceValues do
|
|
129
129
|
feature_type_name IS NOT NULL
|
130
130
|
;
|
131
131
|
|
132
|
-
ANALYZE feature_type_stage;
|
132
|
+
VACUUM FULL ANALYZE feature_type_stage;
|
133
133
|
|
134
134
|
BEGIN;
|
135
135
|
LOCK TABLE feature_type IN EXCLUSIVE MODE;
|
@@ -148,7 +148,7 @@ describe Masamune::Transform::InsertReferenceValues do
|
|
148
148
|
feature_type.name IS NULL
|
149
149
|
;
|
150
150
|
|
151
|
-
ANALYZE feature_type;
|
151
|
+
VACUUM FULL ANALYZE feature_type;
|
152
152
|
|
153
153
|
COMMIT;
|
154
154
|
EOS
|
@@ -172,7 +172,7 @@ describe Masamune::Transform::RollupFact do
|
|
172
172
|
CREATE INDEX visits_hourly_fact_y2014m08_d8b1c3e_index ON visits_hourly_fact_y2014m08 (user_agent_type_id);
|
173
173
|
CREATE INDEX visits_hourly_fact_y2014m08_39f0fdd_index ON visits_hourly_fact_y2014m08 (user_dimension_id);
|
174
174
|
|
175
|
-
ANALYZE visits_hourly_fact_y2014m08;
|
175
|
+
VACUUM FULL ANALYZE visits_hourly_fact_y2014m08;
|
176
176
|
|
177
177
|
COMMIT;
|
178
178
|
|
@@ -274,7 +274,7 @@ describe Masamune::Transform::RollupFact do
|
|
274
274
|
CREATE INDEX visits_daily_fact_y2014m08_d8b1c3e_index ON visits_daily_fact_y2014m08 (user_agent_type_id);
|
275
275
|
CREATE INDEX visits_daily_fact_y2014m08_39f0fdd_index ON visits_daily_fact_y2014m08 (user_dimension_id);
|
276
276
|
|
277
|
-
ANALYZE visits_daily_fact_y2014m08;
|
277
|
+
VACUUM FULL ANALYZE visits_daily_fact_y2014m08;
|
278
278
|
|
279
279
|
COMMIT;
|
280
280
|
|
@@ -376,7 +376,7 @@ describe Masamune::Transform::RollupFact do
|
|
376
376
|
CREATE INDEX visits_monthly_fact_y2014m08_d8b1c3e_index ON visits_monthly_fact_y2014m08 (user_agent_type_id);
|
377
377
|
CREATE INDEX visits_monthly_fact_y2014m08_39f0fdd_index ON visits_monthly_fact_y2014m08 (user_dimension_id);
|
378
378
|
|
379
|
-
ANALYZE visits_monthly_fact_y2014m08;
|
379
|
+
VACUUM FULL ANALYZE visits_monthly_fact_y2014m08;
|
380
380
|
|
381
381
|
COMMIT;
|
382
382
|
|
@@ -110,7 +110,7 @@ describe Masamune::Transform::StageDimension do
|
|
110
110
|
hr_user_account_state_type.name = user_file_dimension_ledger_stage.hr_user_account_state_type_name
|
111
111
|
;
|
112
112
|
|
113
|
-
ANALYZE user_dimension_ledger_stage;
|
113
|
+
VACUUM FULL ANALYZE user_dimension_ledger_stage;
|
114
114
|
EOS
|
115
115
|
end
|
116
116
|
end
|
@@ -145,28 +145,33 @@ describe Masamune::Transform::StageFact do
|
|
145
145
|
JOIN
|
146
146
|
user_dimension
|
147
147
|
ON
|
148
|
+
user_dimension.cluster_type_id = default_cluster_type_id() AND
|
148
149
|
user_dimension.user_id = visits_hourly_file_fact_stage.user_dimension_user_id AND
|
149
150
|
((TO_TIMESTAMP(visits_hourly_file_fact_stage.time_key) BETWEEN user_dimension.start_at AND COALESCE(user_dimension.end_at, 'INFINITY')) OR (TO_TIMESTAMP(visits_hourly_file_fact_stage.time_key) < user_dimension.start_at AND user_dimension.version = 1))
|
150
151
|
JOIN
|
151
152
|
group_dimension AS from_group_dimension
|
152
153
|
ON
|
154
|
+
from_group_dimension.cluster_type_id = default_cluster_type_id() AND
|
153
155
|
from_group_dimension.group_id = COALESCE(visits_hourly_file_fact_stage.from_group_dimension_group_id, missing_group_dimension_group_id()) AND
|
154
156
|
from_group_dimension.group_mode = COALESCE(visits_hourly_file_fact_stage.from_group_dimension_group_mode, missing_group_dimension_group_mode()) AND
|
155
157
|
((TO_TIMESTAMP(visits_hourly_file_fact_stage.time_key) BETWEEN from_group_dimension.start_at AND COALESCE(from_group_dimension.end_at, 'INFINITY')) OR (TO_TIMESTAMP(visits_hourly_file_fact_stage.time_key) < from_group_dimension.start_at AND from_group_dimension.version = 1))
|
156
158
|
JOIN
|
157
159
|
group_dimension
|
158
160
|
ON
|
161
|
+
group_dimension.cluster_type_id = default_cluster_type_id() AND
|
159
162
|
group_dimension.group_id = COALESCE(visits_hourly_file_fact_stage.group_dimension_group_id, missing_group_dimension_group_id()) AND
|
160
163
|
group_dimension.group_mode = COALESCE(visits_hourly_file_fact_stage.group_dimension_group_mode, missing_group_dimension_group_mode()) AND
|
161
164
|
((TO_TIMESTAMP(visits_hourly_file_fact_stage.time_key) BETWEEN group_dimension.start_at AND COALESCE(group_dimension.end_at, 'INFINITY')) OR (TO_TIMESTAMP(visits_hourly_file_fact_stage.time_key) < group_dimension.start_at AND group_dimension.version = 1))
|
162
165
|
JOIN
|
163
166
|
tenant_dimension
|
164
167
|
ON
|
168
|
+
tenant_dimension.cluster_type_id = default_cluster_type_id() AND
|
165
169
|
tenant_dimension.tenant_id = COALESCE(visits_hourly_file_fact_stage.tenant_dimension_tenant_id, user_dimension.tenant_id, from_group_dimension.tenant_id, group_dimension.tenant_id) AND
|
166
170
|
((TO_TIMESTAMP(visits_hourly_file_fact_stage.time_key) BETWEEN tenant_dimension.start_at AND COALESCE(tenant_dimension.end_at, 'INFINITY')) OR (TO_TIMESTAMP(visits_hourly_file_fact_stage.time_key) < tenant_dimension.start_at AND tenant_dimension.version = 1))
|
167
171
|
JOIN
|
168
172
|
user_agent_type
|
169
173
|
ON
|
174
|
+
user_agent_type.cluster_type_id = default_cluster_type_id() AND
|
170
175
|
user_agent_type.name = visits_hourly_file_fact_stage.user_agent_type_name AND
|
171
176
|
user_agent_type.version = COALESCE(visits_hourly_file_fact_stage.user_agent_type_version, 'Unknown') AND
|
172
177
|
user_agent_type.mobile = COALESCE(visits_hourly_file_fact_stage.user_agent_type_mobile, FALSE)
|
@@ -232,7 +237,7 @@ describe Masamune::Transform::StageFact do
|
|
232
237
|
CREATE INDEX visits_hourly_fact_y2014m08_d8b1c3e_index ON visits_hourly_fact_y2014m08 (user_agent_type_id);
|
233
238
|
CREATE INDEX visits_hourly_fact_y2014m08_39f0fdd_index ON visits_hourly_fact_y2014m08 (user_dimension_id);
|
234
239
|
|
235
|
-
ANALYZE visits_hourly_fact_y2014m08;
|
240
|
+
VACUUM FULL ANALYZE visits_hourly_fact_y2014m08;
|
236
241
|
|
237
242
|
COMMIT;
|
238
243
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: masamune
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.13.
|
4
|
+
version: 0.13.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Michael Andrews
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-10-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: thor
|