masamune 0.12.3 → 0.13.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (33) hide show
  1. checksums.yaml +4 -4
  2. data/bin/masamune-dump +4 -0
  3. data/lib/masamune/schema/column.rb +2 -20
  4. data/lib/masamune/schema/dimension.rb +12 -11
  5. data/lib/masamune/schema/fact.rb +10 -1
  6. data/lib/masamune/schema/map.rb +3 -3
  7. data/lib/masamune/schema/row.rb +1 -1
  8. data/lib/masamune/schema/table.rb +55 -23
  9. data/lib/masamune/schema/table_reference.rb +5 -0
  10. data/lib/masamune/tasks/dump_thor.rb +58 -0
  11. data/lib/masamune/tasks/shell_thor.rb +0 -19
  12. data/lib/masamune/template.rb +1 -2
  13. data/lib/masamune/transform/define_foreign_key.psql.erb +39 -0
  14. data/lib/masamune/transform/define_index.psql.erb +7 -3
  15. data/lib/masamune/transform/define_schema.rb +3 -3
  16. data/lib/masamune/transform/define_table.psql.erb +24 -3
  17. data/lib/masamune/transform/define_table.rb +16 -2
  18. data/lib/masamune/transform/define_unique.psql.erb +1 -1
  19. data/lib/masamune/transform/denormalize_table.rb +5 -1
  20. data/lib/masamune/transform/replace_table.psql.erb +9 -13
  21. data/lib/masamune/transform/stage_fact.rb +16 -10
  22. data/lib/masamune/version.rb +1 -1
  23. data/spec/masamune/schema/map_spec.rb +1 -1
  24. data/spec/masamune/tasks/dump_thor_spec.rb +42 -0
  25. data/spec/masamune/tasks/shell_thor_spec.rb +0 -11
  26. data/spec/masamune/template_spec.rb +5 -0
  27. data/spec/masamune/transform/define_table.dimension_spec.rb +81 -52
  28. data/spec/masamune/transform/define_table.fact_spec.rb +27 -63
  29. data/spec/masamune/transform/define_table.table_spec.rb +397 -32
  30. data/spec/masamune/transform/denormalize_table_spec.rb +20 -0
  31. data/spec/masamune/transform/rollup_fact_spec.rb +54 -54
  32. data/spec/masamune/transform/stage_fact_spec.rb +57 -34
  33. metadata +9 -3
@@ -43,6 +43,7 @@ describe Masamune::Transform::DenormalizeTable do
43
43
  dimension 'user', type: :two do
44
44
  column 'tenant_id', type: :integer, index: true, natural_key: true
45
45
  column 'user_id', type: :integer, index: true, natural_key: true
46
+ column 'name', type: :string
46
47
  end
47
48
 
48
49
  dimension 'user_agent', type: :mini do
@@ -56,6 +57,7 @@ describe Masamune::Transform::DenormalizeTable do
56
57
  references :cluster
57
58
  references :date
58
59
  references :tenant
60
+ references :user, label: 'manager'
59
61
  references :user
60
62
  references :user_agent
61
63
  measure 'total', type: :integer
@@ -74,6 +76,8 @@ describe Masamune::Transform::DenormalizeTable do
74
76
  columns: [
75
77
  'date.date_id',
76
78
  'tenant.tenant_id',
79
+ 'manager_user.tenant_id',
80
+ 'manager_user.user_id',
77
81
  'user.tenant_id',
78
82
  'user.user_id',
79
83
  'user_agent.name',
@@ -89,6 +93,8 @@ describe Masamune::Transform::DenormalizeTable do
89
93
  SELECT
90
94
  date_dimension.date_id AS date_dimension_date_id,
91
95
  tenant_dimension.tenant_id AS tenant_dimension_tenant_id,
96
+ manager_user_dimension.tenant_id AS manager_user_dimension_tenant_id,
97
+ manager_user_dimension.user_id AS manager_user_dimension_user_id,
92
98
  user_dimension.tenant_id AS user_dimension_tenant_id,
93
99
  user_dimension.user_id AS user_dimension_user_id,
94
100
  user_agent_type.name AS user_agent_type_name,
@@ -105,6 +111,10 @@ describe Masamune::Transform::DenormalizeTable do
105
111
  tenant_dimension
106
112
  ON
107
113
  tenant_dimension.id = visits_fact.tenant_dimension_id
114
+ LEFT JOIN
115
+ user_dimension AS manager_user_dimension
116
+ ON
117
+ manager_user_dimension.id = visits_fact.manager_user_dimension_id
108
118
  LEFT JOIN
109
119
  user_dimension
110
120
  ON
@@ -116,6 +126,8 @@ describe Masamune::Transform::DenormalizeTable do
116
126
  ORDER BY
117
127
  date_dimension_date_id,
118
128
  tenant_dimension_tenant_id,
129
+ manager_user_dimension_tenant_id,
130
+ manager_user_dimension_user_id,
119
131
  user_dimension_tenant_id,
120
132
  user_dimension_user_id,
121
133
  user_agent_type_name,
@@ -143,6 +155,8 @@ describe Masamune::Transform::DenormalizeTable do
143
155
  SELECT
144
156
  date_dimension.date_id AS date_dimension_date_id,
145
157
  tenant_dimension.tenant_id AS tenant_dimension_tenant_id,
158
+ manager_user_dimension.tenant_id AS manager_user_dimension_tenant_id,
159
+ manager_user_dimension.user_id AS manager_user_dimension_user_id,
146
160
  user_dimension.tenant_id AS user_dimension_tenant_id,
147
161
  user_dimension.user_id AS user_dimension_user_id,
148
162
  user_agent_type.name AS user_agent_type_name,
@@ -160,6 +174,10 @@ describe Masamune::Transform::DenormalizeTable do
160
174
  tenant_dimension
161
175
  ON
162
176
  tenant_dimension.id = visits_fact.tenant_dimension_id
177
+ LEFT JOIN
178
+ user_dimension AS manager_user_dimension
179
+ ON
180
+ manager_user_dimension.id = visits_fact.manager_user_dimension_id
163
181
  LEFT JOIN
164
182
  user_dimension
165
183
  ON
@@ -171,6 +189,8 @@ describe Masamune::Transform::DenormalizeTable do
171
189
  ORDER BY
172
190
  date_dimension_date_id,
173
191
  tenant_dimension_tenant_id,
192
+ manager_user_dimension_tenant_id,
193
+ manager_user_dimension_user_id,
174
194
  user_dimension_tenant_id,
175
195
  user_dimension_user_id,
176
196
  user_agent_type_name,
@@ -136,40 +136,40 @@ describe Masamune::Transform::RollupFact do
136
136
  SET TRANSACTION ISOLATION LEVEL SERIALIZABLE;
137
137
 
138
138
  ALTER TABLE visits_hourly_fact_y2014m08 DROP CONSTRAINT IF EXISTS visits_hourly_fact_y2014m08_time_key_check;
139
- ALTER TABLE visits_hourly_fact_y2014m08 DROP CONSTRAINT IF EXISTS visits_hourly_fact_y2014m08_cluster_type_id_fkey CASCADE;
140
- ALTER TABLE visits_hourly_fact_y2014m08 DROP CONSTRAINT IF EXISTS visits_hourly_fact_y2014m08_date_dimension_id_fkey CASCADE;
141
- ALTER TABLE visits_hourly_fact_y2014m08 DROP CONSTRAINT IF EXISTS visits_hourly_fact_y2014m08_tenant_dimension_id_fkey CASCADE;
142
- ALTER TABLE visits_hourly_fact_y2014m08 DROP CONSTRAINT IF EXISTS visits_hourly_fact_y2014m08_user_dimension_id_fkey CASCADE;
143
- ALTER TABLE visits_hourly_fact_y2014m08 DROP CONSTRAINT IF EXISTS visits_hourly_fact_y2014m08_user_agent_type_id_fkey CASCADE;
144
- ALTER TABLE visits_hourly_fact_y2014m08 DROP CONSTRAINT IF EXISTS visits_hourly_fact_y2014m08_feature_type_id_fkey CASCADE;
139
+ ALTER TABLE visits_hourly_fact_y2014m08 DROP CONSTRAINT IF EXISTS visits_hourly_fact_y2014m08_d6b9b38_fkey CASCADE;
140
+ ALTER TABLE visits_hourly_fact_y2014m08 DROP CONSTRAINT IF EXISTS visits_hourly_fact_y2014m08_0a531a8_fkey CASCADE;
141
+ ALTER TABLE visits_hourly_fact_y2014m08 DROP CONSTRAINT IF EXISTS visits_hourly_fact_y2014m08_d3950d9_fkey CASCADE;
142
+ ALTER TABLE visits_hourly_fact_y2014m08 DROP CONSTRAINT IF EXISTS visits_hourly_fact_y2014m08_39f0fdd_fkey CASCADE;
143
+ ALTER TABLE visits_hourly_fact_y2014m08 DROP CONSTRAINT IF EXISTS visits_hourly_fact_y2014m08_d8b1c3e_fkey CASCADE;
144
+ ALTER TABLE visits_hourly_fact_y2014m08 DROP CONSTRAINT IF EXISTS visits_hourly_fact_y2014m08_33b68fd_fkey CASCADE;
145
145
 
146
146
  DROP INDEX IF EXISTS visits_hourly_fact_y2014m08_d6b9b38_index;
147
147
  DROP INDEX IF EXISTS visits_hourly_fact_y2014m08_0a531a8_index;
148
- DROP INDEX IF EXISTS visits_hourly_fact_y2014m08_d3950d9_index;
149
- DROP INDEX IF EXISTS visits_hourly_fact_y2014m08_39f0fdd_index;
150
- DROP INDEX IF EXISTS visits_hourly_fact_y2014m08_d8b1c3e_index;
151
148
  DROP INDEX IF EXISTS visits_hourly_fact_y2014m08_33b68fd_index;
149
+ DROP INDEX IF EXISTS visits_hourly_fact_y2014m08_d3950d9_index;
152
150
  DROP INDEX IF EXISTS visits_hourly_fact_y2014m08_6444ed3_index;
151
+ DROP INDEX IF EXISTS visits_hourly_fact_y2014m08_d8b1c3e_index;
152
+ DROP INDEX IF EXISTS visits_hourly_fact_y2014m08_39f0fdd_index;
153
153
 
154
154
  ALTER TABLE visits_hourly_fact_y2014m08 RENAME TO visits_hourly_fact_y2014m08_stage_tmp;
155
155
  ALTER TABLE visits_hourly_fact_y2014m08_stage RENAME TO visits_hourly_fact_y2014m08;
156
156
 
157
157
  ALTER TABLE visits_hourly_fact_y2014m08 INHERIT visits_hourly_fact;
158
158
  ALTER TABLE visits_hourly_fact_y2014m08 ADD CONSTRAINT visits_hourly_fact_y2014m08_time_key_check CHECK (time_key >= 1406851200 AND time_key < 1409529600);
159
- ALTER TABLE visits_hourly_fact_y2014m08 ADD CONSTRAINT visits_hourly_fact_y2014m08_cluster_type_id_fkey FOREIGN KEY (cluster_type_id) REFERENCES cluster_type(id) NOT VALID DEFERRABLE INITIALLY DEFERRED;
160
- ALTER TABLE visits_hourly_fact_y2014m08 ADD CONSTRAINT visits_hourly_fact_y2014m08_date_dimension_id_fkey FOREIGN KEY (date_dimension_id) REFERENCES date_dimension(id) NOT VALID DEFERRABLE INITIALLY DEFERRED;
161
- ALTER TABLE visits_hourly_fact_y2014m08 ADD CONSTRAINT visits_hourly_fact_y2014m08_tenant_dimension_id_fkey FOREIGN KEY (tenant_dimension_id) REFERENCES tenant_dimension(id) NOT VALID DEFERRABLE INITIALLY DEFERRED;
162
- ALTER TABLE visits_hourly_fact_y2014m08 ADD CONSTRAINT visits_hourly_fact_y2014m08_user_dimension_id_fkey FOREIGN KEY (user_dimension_id) REFERENCES user_dimension(id) NOT VALID DEFERRABLE INITIALLY DEFERRED;
163
- ALTER TABLE visits_hourly_fact_y2014m08 ADD CONSTRAINT visits_hourly_fact_y2014m08_user_agent_type_id_fkey FOREIGN KEY (user_agent_type_id) REFERENCES user_agent_type(id) NOT VALID DEFERRABLE INITIALLY DEFERRED;
164
- ALTER TABLE visits_hourly_fact_y2014m08 ADD CONSTRAINT visits_hourly_fact_y2014m08_feature_type_id_fkey FOREIGN KEY (feature_type_id) REFERENCES feature_type(id) NOT VALID DEFERRABLE INITIALLY DEFERRED;
159
+ ALTER TABLE visits_hourly_fact_y2014m08 ADD CONSTRAINT visits_hourly_fact_y2014m08_d6b9b38_fkey FOREIGN KEY (cluster_type_id) REFERENCES cluster_type(id) NOT VALID DEFERRABLE INITIALLY DEFERRED;
160
+ ALTER TABLE visits_hourly_fact_y2014m08 ADD CONSTRAINT visits_hourly_fact_y2014m08_0a531a8_fkey FOREIGN KEY (date_dimension_id) REFERENCES date_dimension(id) NOT VALID DEFERRABLE INITIALLY DEFERRED;
161
+ ALTER TABLE visits_hourly_fact_y2014m08 ADD CONSTRAINT visits_hourly_fact_y2014m08_d3950d9_fkey FOREIGN KEY (tenant_dimension_id) REFERENCES tenant_dimension(id) NOT VALID DEFERRABLE INITIALLY DEFERRED;
162
+ ALTER TABLE visits_hourly_fact_y2014m08 ADD CONSTRAINT visits_hourly_fact_y2014m08_39f0fdd_fkey FOREIGN KEY (user_dimension_id) REFERENCES user_dimension(id) NOT VALID DEFERRABLE INITIALLY DEFERRED;
163
+ ALTER TABLE visits_hourly_fact_y2014m08 ADD CONSTRAINT visits_hourly_fact_y2014m08_d8b1c3e_fkey FOREIGN KEY (user_agent_type_id) REFERENCES user_agent_type(id) NOT VALID DEFERRABLE INITIALLY DEFERRED;
164
+ ALTER TABLE visits_hourly_fact_y2014m08 ADD CONSTRAINT visits_hourly_fact_y2014m08_33b68fd_fkey FOREIGN KEY (feature_type_id) REFERENCES feature_type(id) NOT VALID DEFERRABLE INITIALLY DEFERRED;
165
165
 
166
166
  CREATE INDEX visits_hourly_fact_y2014m08_d6b9b38_index ON visits_hourly_fact_y2014m08 (cluster_type_id);
167
167
  CREATE INDEX visits_hourly_fact_y2014m08_0a531a8_index ON visits_hourly_fact_y2014m08 (date_dimension_id);
168
- CREATE INDEX visits_hourly_fact_y2014m08_d3950d9_index ON visits_hourly_fact_y2014m08 (tenant_dimension_id);
169
- CREATE INDEX visits_hourly_fact_y2014m08_39f0fdd_index ON visits_hourly_fact_y2014m08 (user_dimension_id);
170
- CREATE INDEX visits_hourly_fact_y2014m08_d8b1c3e_index ON visits_hourly_fact_y2014m08 (user_agent_type_id);
171
168
  CREATE INDEX visits_hourly_fact_y2014m08_33b68fd_index ON visits_hourly_fact_y2014m08 (feature_type_id);
169
+ CREATE INDEX visits_hourly_fact_y2014m08_d3950d9_index ON visits_hourly_fact_y2014m08 (tenant_dimension_id);
172
170
  CREATE INDEX visits_hourly_fact_y2014m08_6444ed3_index ON visits_hourly_fact_y2014m08 (time_key);
171
+ CREATE INDEX visits_hourly_fact_y2014m08_d8b1c3e_index ON visits_hourly_fact_y2014m08 (user_agent_type_id);
172
+ CREATE INDEX visits_hourly_fact_y2014m08_39f0fdd_index ON visits_hourly_fact_y2014m08 (user_dimension_id);
173
173
 
174
174
  ANALYZE visits_hourly_fact_y2014m08;
175
175
 
@@ -237,40 +237,40 @@ describe Masamune::Transform::RollupFact do
237
237
  SET TRANSACTION ISOLATION LEVEL SERIALIZABLE;
238
238
 
239
239
  ALTER TABLE visits_daily_fact_y2014m08 DROP CONSTRAINT IF EXISTS visits_daily_fact_y2014m08_time_key_check;
240
- ALTER TABLE visits_daily_fact_y2014m08 DROP CONSTRAINT IF EXISTS visits_daily_fact_y2014m08_cluster_type_id_fkey CASCADE;
241
- ALTER TABLE visits_daily_fact_y2014m08 DROP CONSTRAINT IF EXISTS visits_daily_fact_y2014m08_date_dimension_id_fkey CASCADE;
242
- ALTER TABLE visits_daily_fact_y2014m08 DROP CONSTRAINT IF EXISTS visits_daily_fact_y2014m08_tenant_dimension_id_fkey CASCADE;
243
- ALTER TABLE visits_daily_fact_y2014m08 DROP CONSTRAINT IF EXISTS visits_daily_fact_y2014m08_user_dimension_id_fkey CASCADE;
244
- ALTER TABLE visits_daily_fact_y2014m08 DROP CONSTRAINT IF EXISTS visits_daily_fact_y2014m08_user_agent_type_id_fkey CASCADE;
245
- ALTER TABLE visits_daily_fact_y2014m08 DROP CONSTRAINT IF EXISTS visits_daily_fact_y2014m08_feature_type_id_fkey CASCADE;
240
+ ALTER TABLE visits_daily_fact_y2014m08 DROP CONSTRAINT IF EXISTS visits_daily_fact_y2014m08_d6b9b38_fkey CASCADE;
241
+ ALTER TABLE visits_daily_fact_y2014m08 DROP CONSTRAINT IF EXISTS visits_daily_fact_y2014m08_0a531a8_fkey CASCADE;
242
+ ALTER TABLE visits_daily_fact_y2014m08 DROP CONSTRAINT IF EXISTS visits_daily_fact_y2014m08_d3950d9_fkey CASCADE;
243
+ ALTER TABLE visits_daily_fact_y2014m08 DROP CONSTRAINT IF EXISTS visits_daily_fact_y2014m08_39f0fdd_fkey CASCADE;
244
+ ALTER TABLE visits_daily_fact_y2014m08 DROP CONSTRAINT IF EXISTS visits_daily_fact_y2014m08_d8b1c3e_fkey CASCADE;
245
+ ALTER TABLE visits_daily_fact_y2014m08 DROP CONSTRAINT IF EXISTS visits_daily_fact_y2014m08_33b68fd_fkey CASCADE;
246
246
 
247
247
  DROP INDEX IF EXISTS visits_daily_fact_y2014m08_d6b9b38_index;
248
248
  DROP INDEX IF EXISTS visits_daily_fact_y2014m08_0a531a8_index;
249
- DROP INDEX IF EXISTS visits_daily_fact_y2014m08_d3950d9_index;
250
- DROP INDEX IF EXISTS visits_daily_fact_y2014m08_39f0fdd_index;
251
- DROP INDEX IF EXISTS visits_daily_fact_y2014m08_d8b1c3e_index;
252
249
  DROP INDEX IF EXISTS visits_daily_fact_y2014m08_33b68fd_index;
250
+ DROP INDEX IF EXISTS visits_daily_fact_y2014m08_d3950d9_index;
253
251
  DROP INDEX IF EXISTS visits_daily_fact_y2014m08_6444ed3_index;
252
+ DROP INDEX IF EXISTS visits_daily_fact_y2014m08_d8b1c3e_index;
253
+ DROP INDEX IF EXISTS visits_daily_fact_y2014m08_39f0fdd_index;
254
254
 
255
255
  ALTER TABLE visits_daily_fact_y2014m08 RENAME TO visits_daily_fact_y2014m08_stage_tmp;
256
256
  ALTER TABLE visits_daily_fact_y2014m08_stage RENAME TO visits_daily_fact_y2014m08;
257
257
 
258
258
  ALTER TABLE visits_daily_fact_y2014m08 INHERIT visits_daily_fact;
259
259
  ALTER TABLE visits_daily_fact_y2014m08 ADD CONSTRAINT visits_daily_fact_y2014m08_time_key_check CHECK (time_key >= 1406851200 AND time_key < 1409529600);
260
- ALTER TABLE visits_daily_fact_y2014m08 ADD CONSTRAINT visits_daily_fact_y2014m08_cluster_type_id_fkey FOREIGN KEY (cluster_type_id) REFERENCES cluster_type(id) NOT VALID DEFERRABLE INITIALLY DEFERRED;
261
- ALTER TABLE visits_daily_fact_y2014m08 ADD CONSTRAINT visits_daily_fact_y2014m08_date_dimension_id_fkey FOREIGN KEY (date_dimension_id) REFERENCES date_dimension(id) NOT VALID DEFERRABLE INITIALLY DEFERRED;
262
- ALTER TABLE visits_daily_fact_y2014m08 ADD CONSTRAINT visits_daily_fact_y2014m08_tenant_dimension_id_fkey FOREIGN KEY (tenant_dimension_id) REFERENCES tenant_dimension(id) NOT VALID DEFERRABLE INITIALLY DEFERRED;
263
- ALTER TABLE visits_daily_fact_y2014m08 ADD CONSTRAINT visits_daily_fact_y2014m08_user_dimension_id_fkey FOREIGN KEY (user_dimension_id) REFERENCES user_dimension(id) NOT VALID DEFERRABLE INITIALLY DEFERRED;
264
- ALTER TABLE visits_daily_fact_y2014m08 ADD CONSTRAINT visits_daily_fact_y2014m08_user_agent_type_id_fkey FOREIGN KEY (user_agent_type_id) REFERENCES user_agent_type(id) NOT VALID DEFERRABLE INITIALLY DEFERRED;
265
- ALTER TABLE visits_daily_fact_y2014m08 ADD CONSTRAINT visits_daily_fact_y2014m08_feature_type_id_fkey FOREIGN KEY (feature_type_id) REFERENCES feature_type(id) NOT VALID DEFERRABLE INITIALLY DEFERRED;
260
+ ALTER TABLE visits_daily_fact_y2014m08 ADD CONSTRAINT visits_daily_fact_y2014m08_d6b9b38_fkey FOREIGN KEY (cluster_type_id) REFERENCES cluster_type(id) NOT VALID DEFERRABLE INITIALLY DEFERRED;
261
+ ALTER TABLE visits_daily_fact_y2014m08 ADD CONSTRAINT visits_daily_fact_y2014m08_0a531a8_fkey FOREIGN KEY (date_dimension_id) REFERENCES date_dimension(id) NOT VALID DEFERRABLE INITIALLY DEFERRED;
262
+ ALTER TABLE visits_daily_fact_y2014m08 ADD CONSTRAINT visits_daily_fact_y2014m08_d3950d9_fkey FOREIGN KEY (tenant_dimension_id) REFERENCES tenant_dimension(id) NOT VALID DEFERRABLE INITIALLY DEFERRED;
263
+ ALTER TABLE visits_daily_fact_y2014m08 ADD CONSTRAINT visits_daily_fact_y2014m08_39f0fdd_fkey FOREIGN KEY (user_dimension_id) REFERENCES user_dimension(id) NOT VALID DEFERRABLE INITIALLY DEFERRED;
264
+ ALTER TABLE visits_daily_fact_y2014m08 ADD CONSTRAINT visits_daily_fact_y2014m08_d8b1c3e_fkey FOREIGN KEY (user_agent_type_id) REFERENCES user_agent_type(id) NOT VALID DEFERRABLE INITIALLY DEFERRED;
265
+ ALTER TABLE visits_daily_fact_y2014m08 ADD CONSTRAINT visits_daily_fact_y2014m08_33b68fd_fkey FOREIGN KEY (feature_type_id) REFERENCES feature_type(id) NOT VALID DEFERRABLE INITIALLY DEFERRED;
266
266
 
267
267
  CREATE INDEX visits_daily_fact_y2014m08_d6b9b38_index ON visits_daily_fact_y2014m08 (cluster_type_id);
268
268
  CREATE INDEX visits_daily_fact_y2014m08_0a531a8_index ON visits_daily_fact_y2014m08 (date_dimension_id);
269
- CREATE INDEX visits_daily_fact_y2014m08_d3950d9_index ON visits_daily_fact_y2014m08 (tenant_dimension_id);
270
- CREATE INDEX visits_daily_fact_y2014m08_39f0fdd_index ON visits_daily_fact_y2014m08 (user_dimension_id);
271
- CREATE INDEX visits_daily_fact_y2014m08_d8b1c3e_index ON visits_daily_fact_y2014m08 (user_agent_type_id);
272
269
  CREATE INDEX visits_daily_fact_y2014m08_33b68fd_index ON visits_daily_fact_y2014m08 (feature_type_id);
270
+ CREATE INDEX visits_daily_fact_y2014m08_d3950d9_index ON visits_daily_fact_y2014m08 (tenant_dimension_id);
273
271
  CREATE INDEX visits_daily_fact_y2014m08_6444ed3_index ON visits_daily_fact_y2014m08 (time_key);
272
+ CREATE INDEX visits_daily_fact_y2014m08_d8b1c3e_index ON visits_daily_fact_y2014m08 (user_agent_type_id);
273
+ CREATE INDEX visits_daily_fact_y2014m08_39f0fdd_index ON visits_daily_fact_y2014m08 (user_dimension_id);
274
274
 
275
275
  ANALYZE visits_daily_fact_y2014m08;
276
276
 
@@ -338,40 +338,40 @@ describe Masamune::Transform::RollupFact do
338
338
  SET TRANSACTION ISOLATION LEVEL SERIALIZABLE;
339
339
 
340
340
  ALTER TABLE visits_monthly_fact_y2014m08 DROP CONSTRAINT IF EXISTS visits_monthly_fact_y2014m08_time_key_check;
341
- ALTER TABLE visits_monthly_fact_y2014m08 DROP CONSTRAINT IF EXISTS visits_monthly_fact_y2014m08_cluster_type_id_fkey CASCADE;
342
- ALTER TABLE visits_monthly_fact_y2014m08 DROP CONSTRAINT IF EXISTS visits_monthly_fact_y2014m08_date_dimension_id_fkey CASCADE;
343
- ALTER TABLE visits_monthly_fact_y2014m08 DROP CONSTRAINT IF EXISTS visits_monthly_fact_y2014m08_tenant_dimension_id_fkey CASCADE;
344
- ALTER TABLE visits_monthly_fact_y2014m08 DROP CONSTRAINT IF EXISTS visits_monthly_fact_y2014m08_user_dimension_id_fkey CASCADE;
345
- ALTER TABLE visits_monthly_fact_y2014m08 DROP CONSTRAINT IF EXISTS visits_monthly_fact_y2014m08_user_agent_type_id_fkey CASCADE;
346
- ALTER TABLE visits_monthly_fact_y2014m08 DROP CONSTRAINT IF EXISTS visits_monthly_fact_y2014m08_feature_type_id_fkey CASCADE;
341
+ ALTER TABLE visits_monthly_fact_y2014m08 DROP CONSTRAINT IF EXISTS visits_monthly_fact_y2014m08_d6b9b38_fkey CASCADE;
342
+ ALTER TABLE visits_monthly_fact_y2014m08 DROP CONSTRAINT IF EXISTS visits_monthly_fact_y2014m08_0a531a8_fkey CASCADE;
343
+ ALTER TABLE visits_monthly_fact_y2014m08 DROP CONSTRAINT IF EXISTS visits_monthly_fact_y2014m08_d3950d9_fkey CASCADE;
344
+ ALTER TABLE visits_monthly_fact_y2014m08 DROP CONSTRAINT IF EXISTS visits_monthly_fact_y2014m08_39f0fdd_fkey CASCADE;
345
+ ALTER TABLE visits_monthly_fact_y2014m08 DROP CONSTRAINT IF EXISTS visits_monthly_fact_y2014m08_d8b1c3e_fkey CASCADE;
346
+ ALTER TABLE visits_monthly_fact_y2014m08 DROP CONSTRAINT IF EXISTS visits_monthly_fact_y2014m08_33b68fd_fkey CASCADE;
347
347
 
348
348
  DROP INDEX IF EXISTS visits_monthly_fact_y2014m08_d6b9b38_index;
349
349
  DROP INDEX IF EXISTS visits_monthly_fact_y2014m08_0a531a8_index;
350
- DROP INDEX IF EXISTS visits_monthly_fact_y2014m08_d3950d9_index;
351
- DROP INDEX IF EXISTS visits_monthly_fact_y2014m08_39f0fdd_index;
352
- DROP INDEX IF EXISTS visits_monthly_fact_y2014m08_d8b1c3e_index;
353
350
  DROP INDEX IF EXISTS visits_monthly_fact_y2014m08_33b68fd_index;
351
+ DROP INDEX IF EXISTS visits_monthly_fact_y2014m08_d3950d9_index;
354
352
  DROP INDEX IF EXISTS visits_monthly_fact_y2014m08_6444ed3_index;
353
+ DROP INDEX IF EXISTS visits_monthly_fact_y2014m08_d8b1c3e_index;
354
+ DROP INDEX IF EXISTS visits_monthly_fact_y2014m08_39f0fdd_index;
355
355
 
356
356
  ALTER TABLE visits_monthly_fact_y2014m08 RENAME TO visits_monthly_fact_y2014m08_stage_tmp;
357
357
  ALTER TABLE visits_monthly_fact_y2014m08_stage RENAME TO visits_monthly_fact_y2014m08;
358
358
 
359
359
  ALTER TABLE visits_monthly_fact_y2014m08 INHERIT visits_monthly_fact;
360
360
  ALTER TABLE visits_monthly_fact_y2014m08 ADD CONSTRAINT visits_monthly_fact_y2014m08_time_key_check CHECK (time_key >= 1406851200 AND time_key < 1409529600);
361
- ALTER TABLE visits_monthly_fact_y2014m08 ADD CONSTRAINT visits_monthly_fact_y2014m08_cluster_type_id_fkey FOREIGN KEY (cluster_type_id) REFERENCES cluster_type(id) NOT VALID DEFERRABLE INITIALLY DEFERRED;
362
- ALTER TABLE visits_monthly_fact_y2014m08 ADD CONSTRAINT visits_monthly_fact_y2014m08_date_dimension_id_fkey FOREIGN KEY (date_dimension_id) REFERENCES date_dimension(id) NOT VALID DEFERRABLE INITIALLY DEFERRED;
363
- ALTER TABLE visits_monthly_fact_y2014m08 ADD CONSTRAINT visits_monthly_fact_y2014m08_tenant_dimension_id_fkey FOREIGN KEY (tenant_dimension_id) REFERENCES tenant_dimension(id) NOT VALID DEFERRABLE INITIALLY DEFERRED;
364
- ALTER TABLE visits_monthly_fact_y2014m08 ADD CONSTRAINT visits_monthly_fact_y2014m08_user_dimension_id_fkey FOREIGN KEY (user_dimension_id) REFERENCES user_dimension(id) NOT VALID DEFERRABLE INITIALLY DEFERRED;
365
- ALTER TABLE visits_monthly_fact_y2014m08 ADD CONSTRAINT visits_monthly_fact_y2014m08_user_agent_type_id_fkey FOREIGN KEY (user_agent_type_id) REFERENCES user_agent_type(id) NOT VALID DEFERRABLE INITIALLY DEFERRED;
366
- ALTER TABLE visits_monthly_fact_y2014m08 ADD CONSTRAINT visits_monthly_fact_y2014m08_feature_type_id_fkey FOREIGN KEY (feature_type_id) REFERENCES feature_type(id) NOT VALID DEFERRABLE INITIALLY DEFERRED;
361
+ ALTER TABLE visits_monthly_fact_y2014m08 ADD CONSTRAINT visits_monthly_fact_y2014m08_d6b9b38_fkey FOREIGN KEY (cluster_type_id) REFERENCES cluster_type(id) NOT VALID DEFERRABLE INITIALLY DEFERRED;
362
+ ALTER TABLE visits_monthly_fact_y2014m08 ADD CONSTRAINT visits_monthly_fact_y2014m08_0a531a8_fkey FOREIGN KEY (date_dimension_id) REFERENCES date_dimension(id) NOT VALID DEFERRABLE INITIALLY DEFERRED;
363
+ ALTER TABLE visits_monthly_fact_y2014m08 ADD CONSTRAINT visits_monthly_fact_y2014m08_d3950d9_fkey FOREIGN KEY (tenant_dimension_id) REFERENCES tenant_dimension(id) NOT VALID DEFERRABLE INITIALLY DEFERRED;
364
+ ALTER TABLE visits_monthly_fact_y2014m08 ADD CONSTRAINT visits_monthly_fact_y2014m08_39f0fdd_fkey FOREIGN KEY (user_dimension_id) REFERENCES user_dimension(id) NOT VALID DEFERRABLE INITIALLY DEFERRED;
365
+ ALTER TABLE visits_monthly_fact_y2014m08 ADD CONSTRAINT visits_monthly_fact_y2014m08_d8b1c3e_fkey FOREIGN KEY (user_agent_type_id) REFERENCES user_agent_type(id) NOT VALID DEFERRABLE INITIALLY DEFERRED;
366
+ ALTER TABLE visits_monthly_fact_y2014m08 ADD CONSTRAINT visits_monthly_fact_y2014m08_33b68fd_fkey FOREIGN KEY (feature_type_id) REFERENCES feature_type(id) NOT VALID DEFERRABLE INITIALLY DEFERRED;
367
367
 
368
368
  CREATE INDEX visits_monthly_fact_y2014m08_d6b9b38_index ON visits_monthly_fact_y2014m08 (cluster_type_id);
369
369
  CREATE INDEX visits_monthly_fact_y2014m08_0a531a8_index ON visits_monthly_fact_y2014m08 (date_dimension_id);
370
- CREATE INDEX visits_monthly_fact_y2014m08_d3950d9_index ON visits_monthly_fact_y2014m08 (tenant_dimension_id);
371
- CREATE INDEX visits_monthly_fact_y2014m08_39f0fdd_index ON visits_monthly_fact_y2014m08 (user_dimension_id);
372
- CREATE INDEX visits_monthly_fact_y2014m08_d8b1c3e_index ON visits_monthly_fact_y2014m08 (user_agent_type_id);
373
370
  CREATE INDEX visits_monthly_fact_y2014m08_33b68fd_index ON visits_monthly_fact_y2014m08 (feature_type_id);
371
+ CREATE INDEX visits_monthly_fact_y2014m08_d3950d9_index ON visits_monthly_fact_y2014m08 (tenant_dimension_id);
374
372
  CREATE INDEX visits_monthly_fact_y2014m08_6444ed3_index ON visits_monthly_fact_y2014m08 (time_key);
373
+ CREATE INDEX visits_monthly_fact_y2014m08_d8b1c3e_index ON visits_monthly_fact_y2014m08 (user_agent_type_id);
374
+ CREATE INDEX visits_monthly_fact_y2014m08_39f0fdd_index ON visits_monthly_fact_y2014m08 (user_dimension_id);
375
375
 
376
376
  ANALYZE visits_monthly_fact_y2014m08;
377
377
 
@@ -35,10 +35,12 @@ describe Masamune::Transform::StageFact do
35
35
  end
36
36
 
37
37
  dimension 'date', type: :date do
38
- column 'date_id', type: :integer, unique: true, index: true, natural_key: true
38
+ column 'date_id', type: :integer, natural_key: true
39
39
  end
40
40
 
41
41
  dimension 'user_agent', type: :mini do
42
+ references :cluster
43
+
42
44
  column 'name', type: :string, unique: true, index: 'shared'
43
45
  column 'version', type: :string, unique: true, index: 'shared', default: 'Unknown'
44
46
  column 'mobile', type: :boolean, unique: true, index: 'shared', default: false
@@ -50,16 +52,23 @@ describe Masamune::Transform::StageFact do
50
52
  end
51
53
 
52
54
  dimension 'tenant', type: :two do
53
- column 'tenant_id', type: :integer, index: true, natural_key: true
55
+ references :cluster
56
+
57
+ column 'tenant_id', type: :integer, natural_key: true
54
58
  end
55
59
 
56
60
  dimension 'user', type: :two do
57
- column 'tenant_id', type: :integer, index: true, natural_key: true
58
- column 'user_id', type: :integer, index: true, natural_key: true
61
+ references :cluster
62
+
63
+ column 'tenant_id', type: :integer, natural_key: true
64
+ column 'user_id', type: :integer, natural_key: true
59
65
  end
60
66
 
61
67
  dimension 'group', type: :two do
62
- column 'group_id', type: :integer, index: true, natural_key: true
68
+ references :cluster
69
+
70
+ column 'tenant_id', type: :integer, natural_key: true
71
+ column 'group_id', type: :integer, natural_key: true
63
72
  column 'group_mode', type: :enum, sub_type: 'group_mode', values: %(missing public private), index: true, natural_key: true, default: 'missing'
64
73
  row group_id: -1, group_mode: 'missing', attributes: {id: :missing}
65
74
  end
@@ -67,8 +76,9 @@ describe Masamune::Transform::StageFact do
67
76
  fact 'visits', partition: 'y%Ym%m', grain: %w(hourly daily monthly) do
68
77
  references :cluster
69
78
  references :date
70
- references :tenant
79
+ references :tenant, through: [:user, :from_group, :group]
71
80
  references :user
81
+ references :group, label: 'from', default: :missing
72
82
  references :group, default: :missing
73
83
  references :user_agent, insert: true
74
84
  references :feature, insert: true
@@ -80,6 +90,8 @@ describe Masamune::Transform::StageFact do
80
90
  column 'date.date_id', type: :integer
81
91
  column 'tenant.tenant_id', type: :integer
82
92
  column 'user.user_id', type: :integer
93
+ column 'from_group.group_id', type: :integer
94
+ column 'from_group.group_mode', type: :enum, sub_type: 'group_mode'
83
95
  column 'group.group_id', type: :integer
84
96
  column 'group.group_mode', type: :enum, sub_type: 'group_mode'
85
97
  column 'user_agent.name', type: :string
@@ -112,11 +124,12 @@ describe Masamune::Transform::StageFact do
112
124
  BEGIN;
113
125
 
114
126
  INSERT INTO
115
- visits_hourly_fact_y2014m08_stage (date_dimension_id, tenant_dimension_id, user_dimension_id, group_dimension_id, user_agent_type_id, feature_type_id, session_type_id, total, time_key)
127
+ visits_hourly_fact_y2014m08_stage (date_dimension_id, tenant_dimension_id, user_dimension_id, from_group_dimension_id, group_dimension_id, user_agent_type_id, feature_type_id, session_type_id, total, time_key)
116
128
  SELECT
117
129
  date_dimension.id,
118
130
  tenant_dimension.id,
119
131
  user_dimension.id,
132
+ from_group_dimension.id,
120
133
  group_dimension.id,
121
134
  user_agent_type.id,
122
135
  feature_type.id,
@@ -135,16 +148,22 @@ describe Masamune::Transform::StageFact do
135
148
  user_dimension.user_id = visits_hourly_file_fact_stage.user_dimension_user_id AND
136
149
  ((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))
137
150
  JOIN
138
- tenant_dimension
151
+ group_dimension AS from_group_dimension
139
152
  ON
140
- tenant_dimension.tenant_id = COALESCE(visits_hourly_file_fact_stage.tenant_dimension_tenant_id, user_dimension.tenant_id) AND
141
- ((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))
153
+ from_group_dimension.group_id = COALESCE(visits_hourly_file_fact_stage.from_group_dimension_group_id, missing_group_dimension_group_id()) AND
154
+ from_group_dimension.group_mode = COALESCE(visits_hourly_file_fact_stage.from_group_dimension_group_mode, missing_group_dimension_group_mode()) AND
155
+ ((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))
142
156
  JOIN
143
157
  group_dimension
144
158
  ON
145
- group_dimension.group_id = COALESCE(visits_hourly_file_fact_stage.group_dimension_group_id, missing_group_id()) AND
146
- group_dimension.group_mode = COALESCE(visits_hourly_file_fact_stage.group_dimension_group_mode, missing_group_mode()) AND
159
+ group_dimension.group_id = COALESCE(visits_hourly_file_fact_stage.group_dimension_group_id, missing_group_dimension_group_id()) AND
160
+ group_dimension.group_mode = COALESCE(visits_hourly_file_fact_stage.group_dimension_group_mode, missing_group_dimension_group_mode()) AND
147
161
  ((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
+ JOIN
163
+ tenant_dimension
164
+ ON
165
+ 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
+ ((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))
148
167
  JOIN
149
168
  user_agent_type
150
169
  ON
@@ -167,46 +186,50 @@ describe Masamune::Transform::StageFact do
167
186
  SET TRANSACTION ISOLATION LEVEL SERIALIZABLE;
168
187
 
169
188
  ALTER TABLE visits_hourly_fact_y2014m08 DROP CONSTRAINT IF EXISTS visits_hourly_fact_y2014m08_time_key_check;
170
- ALTER TABLE visits_hourly_fact_y2014m08 DROP CONSTRAINT IF EXISTS visits_hourly_fact_y2014m08_cluster_type_id_fkey CASCADE;
171
- ALTER TABLE visits_hourly_fact_y2014m08 DROP CONSTRAINT IF EXISTS visits_hourly_fact_y2014m08_date_dimension_id_fkey CASCADE;
172
- ALTER TABLE visits_hourly_fact_y2014m08 DROP CONSTRAINT IF EXISTS visits_hourly_fact_y2014m08_tenant_dimension_id_fkey CASCADE;
173
- ALTER TABLE visits_hourly_fact_y2014m08 DROP CONSTRAINT IF EXISTS visits_hourly_fact_y2014m08_user_dimension_id_fkey CASCADE;
174
- ALTER TABLE visits_hourly_fact_y2014m08 DROP CONSTRAINT IF EXISTS visits_hourly_fact_y2014m08_group_dimension_id_fkey CASCADE;
175
- ALTER TABLE visits_hourly_fact_y2014m08 DROP CONSTRAINT IF EXISTS visits_hourly_fact_y2014m08_user_agent_type_id_fkey CASCADE;
176
- ALTER TABLE visits_hourly_fact_y2014m08 DROP CONSTRAINT IF EXISTS visits_hourly_fact_y2014m08_feature_type_id_fkey CASCADE;
189
+ ALTER TABLE visits_hourly_fact_y2014m08 DROP CONSTRAINT IF EXISTS visits_hourly_fact_y2014m08_d6b9b38_fkey CASCADE;
190
+ ALTER TABLE visits_hourly_fact_y2014m08 DROP CONSTRAINT IF EXISTS visits_hourly_fact_y2014m08_0a531a8_fkey CASCADE;
191
+ ALTER TABLE visits_hourly_fact_y2014m08 DROP CONSTRAINT IF EXISTS visits_hourly_fact_y2014m08_ff74c56_fkey CASCADE;
192
+ ALTER TABLE visits_hourly_fact_y2014m08 DROP CONSTRAINT IF EXISTS visits_hourly_fact_y2014m08_1aeb6c0_fkey CASCADE;
193
+ ALTER TABLE visits_hourly_fact_y2014m08 DROP CONSTRAINT IF EXISTS visits_hourly_fact_y2014m08_47d54be_fkey CASCADE;
194
+ ALTER TABLE visits_hourly_fact_y2014m08 DROP CONSTRAINT IF EXISTS visits_hourly_fact_y2014m08_b4cc377_fkey CASCADE;
195
+ ALTER TABLE visits_hourly_fact_y2014m08 DROP CONSTRAINT IF EXISTS visits_hourly_fact_y2014m08_13f0010_fkey CASCADE;
196
+ ALTER TABLE visits_hourly_fact_y2014m08 DROP CONSTRAINT IF EXISTS visits_hourly_fact_y2014m08_33b68fd_fkey CASCADE;
177
197
 
178
198
  DROP INDEX IF EXISTS visits_hourly_fact_y2014m08_d6b9b38_index;
179
199
  DROP INDEX IF EXISTS visits_hourly_fact_y2014m08_0a531a8_index;
180
- DROP INDEX IF EXISTS visits_hourly_fact_y2014m08_d3950d9_index;
181
- DROP INDEX IF EXISTS visits_hourly_fact_y2014m08_39f0fdd_index;
182
- DROP INDEX IF EXISTS visits_hourly_fact_y2014m08_e0d2a9e_index;
183
- DROP INDEX IF EXISTS visits_hourly_fact_y2014m08_d8b1c3e_index;
184
200
  DROP INDEX IF EXISTS visits_hourly_fact_y2014m08_33b68fd_index;
201
+ DROP INDEX IF EXISTS visits_hourly_fact_y2014m08_e67f99d_index;
202
+ DROP INDEX IF EXISTS visits_hourly_fact_y2014m08_e0d2a9e_index;
185
203
  DROP INDEX IF EXISTS visits_hourly_fact_y2014m08_422efee_index;
204
+ DROP INDEX IF EXISTS visits_hourly_fact_y2014m08_d3950d9_index;
186
205
  DROP INDEX IF EXISTS visits_hourly_fact_y2014m08_6444ed3_index;
206
+ DROP INDEX IF EXISTS visits_hourly_fact_y2014m08_d8b1c3e_index;
207
+ DROP INDEX IF EXISTS visits_hourly_fact_y2014m08_39f0fdd_index;
187
208
 
188
209
  ALTER TABLE visits_hourly_fact_y2014m08 RENAME TO visits_hourly_fact_y2014m08_stage_tmp;
189
210
  ALTER TABLE visits_hourly_fact_y2014m08_stage RENAME TO visits_hourly_fact_y2014m08;
190
211
 
191
212
  ALTER TABLE visits_hourly_fact_y2014m08 INHERIT visits_hourly_fact;
192
213
  ALTER TABLE visits_hourly_fact_y2014m08 ADD CONSTRAINT visits_hourly_fact_y2014m08_time_key_check CHECK (time_key >= 1406851200 AND time_key < 1409529600);
193
- ALTER TABLE visits_hourly_fact_y2014m08 ADD CONSTRAINT visits_hourly_fact_y2014m08_cluster_type_id_fkey FOREIGN KEY (cluster_type_id) REFERENCES cluster_type(id) NOT VALID DEFERRABLE INITIALLY DEFERRED;
194
- ALTER TABLE visits_hourly_fact_y2014m08 ADD CONSTRAINT visits_hourly_fact_y2014m08_date_dimension_id_fkey FOREIGN KEY (date_dimension_id) REFERENCES date_dimension(id) NOT VALID DEFERRABLE INITIALLY DEFERRED;
195
- ALTER TABLE visits_hourly_fact_y2014m08 ADD CONSTRAINT visits_hourly_fact_y2014m08_tenant_dimension_id_fkey FOREIGN KEY (tenant_dimension_id) REFERENCES tenant_dimension(id) NOT VALID DEFERRABLE INITIALLY DEFERRED;
196
- ALTER TABLE visits_hourly_fact_y2014m08 ADD CONSTRAINT visits_hourly_fact_y2014m08_user_dimension_id_fkey FOREIGN KEY (user_dimension_id) REFERENCES user_dimension(id) NOT VALID DEFERRABLE INITIALLY DEFERRED;
197
- ALTER TABLE visits_hourly_fact_y2014m08 ADD CONSTRAINT visits_hourly_fact_y2014m08_group_dimension_id_fkey FOREIGN KEY (group_dimension_id) REFERENCES group_dimension(id) NOT VALID DEFERRABLE INITIALLY DEFERRED;
198
- ALTER TABLE visits_hourly_fact_y2014m08 ADD CONSTRAINT visits_hourly_fact_y2014m08_user_agent_type_id_fkey FOREIGN KEY (user_agent_type_id) REFERENCES user_agent_type(id) NOT VALID DEFERRABLE INITIALLY DEFERRED;
199
- ALTER TABLE visits_hourly_fact_y2014m08 ADD CONSTRAINT visits_hourly_fact_y2014m08_feature_type_id_fkey FOREIGN KEY (feature_type_id) REFERENCES feature_type(id) NOT VALID DEFERRABLE INITIALLY DEFERRED;
214
+ ALTER TABLE visits_hourly_fact_y2014m08 ADD CONSTRAINT visits_hourly_fact_y2014m08_d6b9b38_fkey FOREIGN KEY (cluster_type_id) REFERENCES cluster_type(id) NOT VALID DEFERRABLE INITIALLY DEFERRED;
215
+ ALTER TABLE visits_hourly_fact_y2014m08 ADD CONSTRAINT visits_hourly_fact_y2014m08_0a531a8_fkey FOREIGN KEY (date_dimension_id) REFERENCES date_dimension(id) NOT VALID DEFERRABLE INITIALLY DEFERRED;
216
+ ALTER TABLE visits_hourly_fact_y2014m08 ADD CONSTRAINT visits_hourly_fact_y2014m08_ff74c56_fkey FOREIGN KEY (cluster_type_id, tenant_dimension_id) REFERENCES tenant_dimension(cluster_type_id, id) NOT VALID DEFERRABLE INITIALLY DEFERRED;
217
+ ALTER TABLE visits_hourly_fact_y2014m08 ADD CONSTRAINT visits_hourly_fact_y2014m08_1aeb6c0_fkey FOREIGN KEY (cluster_type_id, user_dimension_id) REFERENCES user_dimension(cluster_type_id, id) NOT VALID DEFERRABLE INITIALLY DEFERRED;
218
+ ALTER TABLE visits_hourly_fact_y2014m08 ADD CONSTRAINT visits_hourly_fact_y2014m08_47d54be_fkey FOREIGN KEY (cluster_type_id, from_group_dimension_id) REFERENCES group_dimension(cluster_type_id, id) NOT VALID DEFERRABLE INITIALLY DEFERRED;
219
+ ALTER TABLE visits_hourly_fact_y2014m08 ADD CONSTRAINT visits_hourly_fact_y2014m08_b4cc377_fkey FOREIGN KEY (cluster_type_id, group_dimension_id) REFERENCES group_dimension(cluster_type_id, id) NOT VALID DEFERRABLE INITIALLY DEFERRED;
220
+ ALTER TABLE visits_hourly_fact_y2014m08 ADD CONSTRAINT visits_hourly_fact_y2014m08_13f0010_fkey FOREIGN KEY (cluster_type_id, user_agent_type_id) REFERENCES user_agent_type(cluster_type_id, id) NOT VALID DEFERRABLE INITIALLY DEFERRED;
221
+ ALTER TABLE visits_hourly_fact_y2014m08 ADD CONSTRAINT visits_hourly_fact_y2014m08_33b68fd_fkey FOREIGN KEY (feature_type_id) REFERENCES feature_type(id) NOT VALID DEFERRABLE INITIALLY DEFERRED;
200
222
 
201
223
  CREATE INDEX visits_hourly_fact_y2014m08_d6b9b38_index ON visits_hourly_fact_y2014m08 (cluster_type_id);
202
224
  CREATE INDEX visits_hourly_fact_y2014m08_0a531a8_index ON visits_hourly_fact_y2014m08 (date_dimension_id);
203
- CREATE INDEX visits_hourly_fact_y2014m08_d3950d9_index ON visits_hourly_fact_y2014m08 (tenant_dimension_id);
204
- CREATE INDEX visits_hourly_fact_y2014m08_39f0fdd_index ON visits_hourly_fact_y2014m08 (user_dimension_id);
205
- CREATE INDEX visits_hourly_fact_y2014m08_e0d2a9e_index ON visits_hourly_fact_y2014m08 (group_dimension_id);
206
- CREATE INDEX visits_hourly_fact_y2014m08_d8b1c3e_index ON visits_hourly_fact_y2014m08 (user_agent_type_id);
207
225
  CREATE INDEX visits_hourly_fact_y2014m08_33b68fd_index ON visits_hourly_fact_y2014m08 (feature_type_id);
226
+ CREATE INDEX visits_hourly_fact_y2014m08_e67f99d_index ON visits_hourly_fact_y2014m08 (from_group_dimension_id);
227
+ CREATE INDEX visits_hourly_fact_y2014m08_e0d2a9e_index ON visits_hourly_fact_y2014m08 (group_dimension_id);
208
228
  CREATE INDEX visits_hourly_fact_y2014m08_422efee_index ON visits_hourly_fact_y2014m08 (session_type_id);
229
+ CREATE INDEX visits_hourly_fact_y2014m08_d3950d9_index ON visits_hourly_fact_y2014m08 (tenant_dimension_id);
209
230
  CREATE INDEX visits_hourly_fact_y2014m08_6444ed3_index ON visits_hourly_fact_y2014m08 (time_key);
231
+ CREATE INDEX visits_hourly_fact_y2014m08_d8b1c3e_index ON visits_hourly_fact_y2014m08 (user_agent_type_id);
232
+ CREATE INDEX visits_hourly_fact_y2014m08_39f0fdd_index ON visits_hourly_fact_y2014m08 (user_dimension_id);
210
233
 
211
234
  ANALYZE visits_hourly_fact_y2014m08;
212
235
 
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.12.3
4
+ version: 0.13.0
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-08-17 00:00:00.000000000 Z
11
+ date: 2015-09-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: thor
@@ -186,12 +186,14 @@ executables:
186
186
  - masamune-hive
187
187
  - masamune-elastic-mapreduce
188
188
  - masamune-psql
189
+ - masamune-dump
189
190
  extensions: []
190
191
  extra_rdoc_files: []
191
192
  files:
192
193
  - LICENSE.txt
193
194
  - README.md
194
195
  - Rakefile
196
+ - bin/masamune-dump
195
197
  - bin/masamune-elastic-mapreduce
196
198
  - bin/masamune-hive
197
199
  - bin/masamune-psql
@@ -253,6 +255,7 @@ files:
253
255
  - lib/masamune/schema/table_reference.rb
254
256
  - lib/masamune/spec_helper.rb
255
257
  - lib/masamune/string_format.rb
258
+ - lib/masamune/tasks/dump_thor.rb
256
259
  - lib/masamune/tasks/elastic_mapreduce_thor.rb
257
260
  - lib/masamune/tasks/hive_thor.rb
258
261
  - lib/masamune/tasks/postgres_thor.rb
@@ -267,6 +270,7 @@ files:
267
270
  - lib/masamune/transform/consolidate_dimension.rb
268
271
  - lib/masamune/transform/deduplicate_dimension.psql.erb
269
272
  - lib/masamune/transform/deduplicate_dimension.rb
273
+ - lib/masamune/transform/define_foreign_key.psql.erb
270
274
  - lib/masamune/transform/define_index.psql.erb
271
275
  - lib/masamune/transform/define_schema.hql.erb
272
276
  - lib/masamune/transform/define_schema.psql.erb
@@ -339,6 +343,7 @@ files:
339
343
  - spec/masamune/schema/store_spec.rb
340
344
  - spec/masamune/schema/table_spec.rb
341
345
  - spec/masamune/string_format_spec.rb
346
+ - spec/masamune/tasks/dump_thor_spec.rb
342
347
  - spec/masamune/tasks/elastic_mapreduce_thor_spec.rb
343
348
  - spec/masamune/tasks/hive_thor_spec.rb
344
349
  - spec/masamune/tasks/postgres_thor_spec.rb
@@ -392,7 +397,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
392
397
  version: '0'
393
398
  requirements: []
394
399
  rubyforge_project:
395
- rubygems_version: 2.4.6
400
+ rubygems_version: 2.4.8
396
401
  signing_key:
397
402
  specification_version: 4
398
403
  summary: Hybrid Data & Work Flow
@@ -441,6 +446,7 @@ test_files:
441
446
  - spec/masamune/schema/store_spec.rb
442
447
  - spec/masamune/schema/table_spec.rb
443
448
  - spec/masamune/string_format_spec.rb
449
+ - spec/masamune/tasks/dump_thor_spec.rb
444
450
  - spec/masamune/tasks/elastic_mapreduce_thor_spec.rb
445
451
  - spec/masamune/tasks/hive_thor_spec.rb
446
452
  - spec/masamune/tasks/postgres_thor_spec.rb