masamune 0.13.3 → 0.13.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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0b1cfbf2086afb91e515f3350cdefd9edc38b5c5
|
4
|
+
data.tar.gz: 7fd27c38a43dbfaa2b4a75db79207c9da2d412ca
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 665f24b4261a0e9f05367d031de278cf3561e9993b004339feafb0022da22d43ed54be8682b9706e9ffb420ec0ec72bc9167bb54cf3b2e3f68065b05db91dcdb
|
7
|
+
data.tar.gz: 7ab3d42d09761b855abd75210d96c841709bba94bbe591c90844d3199328ffaa84f405708a9b7df198bd14a08c501e21f9fd0dff347f97f84478a63f7c47dc61
|
@@ -39,12 +39,6 @@ SELECT
|
|
39
39
|
<%- end -%>
|
40
40
|
FROM
|
41
41
|
<%= source.name %>
|
42
|
-
<%- target.join_conditions(source).each do |table, conditions| -%>
|
43
|
-
JOIN
|
44
|
-
<%= table %>
|
45
|
-
ON
|
46
|
-
<%= conditions.join(" AND\n ") %>
|
47
|
-
<%- end -%>
|
48
42
|
GROUP BY
|
49
43
|
<%- target.group_by(source).each do |value, last| -%>
|
50
44
|
<%= value %><%= ',' unless last %>
|
@@ -52,7 +52,7 @@ module Masamune::Transform
|
|
52
52
|
|
53
53
|
def insert_values(source)
|
54
54
|
values = []
|
55
|
-
values <<
|
55
|
+
values << calculated_date_key(source)
|
56
56
|
shared_columns(source).values.map do |columns|
|
57
57
|
column = columns.first
|
58
58
|
next unless column.reference
|
@@ -63,7 +63,7 @@ module Masamune::Transform
|
|
63
63
|
source.measures.each do |_ ,measure|
|
64
64
|
values << measure.aggregate_value
|
65
65
|
end
|
66
|
-
values <<
|
66
|
+
values << calculated_time_key(source)
|
67
67
|
values
|
68
68
|
end
|
69
69
|
method_with_last_element :insert_values
|
@@ -78,7 +78,7 @@ module Masamune::Transform
|
|
78
78
|
|
79
79
|
def group_by(source)
|
80
80
|
group_by = []
|
81
|
-
group_by <<
|
81
|
+
group_by << calculated_date_key(source)
|
82
82
|
shared_columns(source).values.map do |columns|
|
83
83
|
column = columns.first
|
84
84
|
next unless column.reference
|
@@ -86,64 +86,33 @@ module Masamune::Transform
|
|
86
86
|
next if column.auto_reference
|
87
87
|
group_by << column.qualified_name
|
88
88
|
end
|
89
|
-
group_by <<
|
89
|
+
group_by << calculated_time_key(source)
|
90
90
|
group_by
|
91
91
|
end
|
92
92
|
method_with_last_element :group_by
|
93
93
|
|
94
94
|
private
|
95
95
|
|
96
|
-
def
|
96
|
+
def calculated_date_key(source)
|
97
97
|
case grain
|
98
|
-
when :hourly
|
99
|
-
|
100
|
-
when :daily
|
101
|
-
:date_epoch
|
98
|
+
when :hourly, :daily
|
99
|
+
"#{source.date_column.qualified_name}"
|
102
100
|
when :monthly
|
103
|
-
|
101
|
+
"to_char(date_trunc('month',#{source.date_column.qualified_name}::text::date),'YYYYMMDD')::integer"
|
104
102
|
end
|
105
103
|
end
|
106
104
|
|
107
|
-
def
|
108
|
-
:date_id
|
109
|
-
end
|
110
|
-
|
111
|
-
def first_date_surrogate_key
|
112
|
-
<<-EOS.gsub(/\s+/, ' ').strip
|
113
|
-
SELECT
|
114
|
-
#{date_column.reference.surrogate_key.name}
|
115
|
-
FROM
|
116
|
-
#{date_column.reference.name} d
|
117
|
-
WHERE
|
118
|
-
d.#{rollup_key} = #{date_column.reference.columns[rollup_key].qualified_name}
|
119
|
-
ORDER BY
|
120
|
-
d.#{date_key}
|
121
|
-
LIMIT 1
|
122
|
-
EOS
|
123
|
-
end
|
124
|
-
|
125
|
-
def floor_time_key(source)
|
105
|
+
def calculated_time_key(source)
|
126
106
|
case grain
|
127
107
|
when :hourly
|
128
|
-
"#{source.time_key.qualified_name} - (#{source.time_key.qualified_name} % #{1.hour.seconds})"
|
129
|
-
when :daily
|
130
|
-
|
108
|
+
"(#{source.time_key.qualified_name} - (#{source.time_key.qualified_name} % #{1.hour.seconds}))"
|
109
|
+
when :daily
|
110
|
+
"extract(EPOCH from #{source.date_column.qualified_name}::text::date)"
|
111
|
+
when :monthly
|
112
|
+
"extract(EPOCH from date_trunc('month',#{source.date_column.qualified_name}::text::date))"
|
131
113
|
end
|
132
114
|
end
|
133
115
|
|
134
|
-
def first_date_time_key
|
135
|
-
<<-EOS.gsub(/\s+/, ' ').strip
|
136
|
-
SELECT
|
137
|
-
#{rollup_key}
|
138
|
-
FROM
|
139
|
-
#{date_column.reference.name} d
|
140
|
-
WHERE
|
141
|
-
d.#{rollup_key} = #{date_column.reference.columns[rollup_key].qualified_name}
|
142
|
-
ORDER BY
|
143
|
-
d.#{date_key}
|
144
|
-
LIMIT 1
|
145
|
-
EOS
|
146
|
-
end
|
147
116
|
end
|
148
117
|
end
|
149
118
|
end
|
data/lib/masamune/version.rb
CHANGED
@@ -104,7 +104,7 @@ describe Masamune::Transform::RollupFact do
|
|
104
104
|
INSERT INTO
|
105
105
|
visits_hourly_fact_y2014m08_stage (date_dimension_id, tenant_dimension_id, user_dimension_id, user_agent_type_id, feature_type_id, total, time_key)
|
106
106
|
SELECT
|
107
|
-
|
107
|
+
visits_transaction_fact_y2014m08.date_dimension_id,
|
108
108
|
visits_transaction_fact_y2014m08.tenant_dimension_id,
|
109
109
|
visits_transaction_fact_y2014m08.user_dimension_id,
|
110
110
|
visits_transaction_fact_y2014m08.user_agent_type_id,
|
@@ -113,12 +113,8 @@ describe Masamune::Transform::RollupFact do
|
|
113
113
|
(visits_transaction_fact_y2014m08.time_key - (visits_transaction_fact_y2014m08.time_key % 3600))
|
114
114
|
FROM
|
115
115
|
visits_transaction_fact_y2014m08
|
116
|
-
JOIN
|
117
|
-
date_dimension
|
118
|
-
ON
|
119
|
-
date_dimension.id = visits_transaction_fact_y2014m08.date_dimension_id
|
120
116
|
GROUP BY
|
121
|
-
|
117
|
+
visits_transaction_fact_y2014m08.date_dimension_id,
|
122
118
|
visits_transaction_fact_y2014m08.tenant_dimension_id,
|
123
119
|
visits_transaction_fact_y2014m08.user_dimension_id,
|
124
120
|
visits_transaction_fact_y2014m08.user_agent_type_id,
|
@@ -207,25 +203,22 @@ describe Masamune::Transform::RollupFact do
|
|
207
203
|
INSERT INTO
|
208
204
|
visits_daily_fact_y2014m08_stage (date_dimension_id, tenant_dimension_id, user_dimension_id, user_agent_type_id, feature_type_id, total, time_key)
|
209
205
|
SELECT
|
210
|
-
|
206
|
+
visits_hourly_fact_y2014m08.date_dimension_id,
|
211
207
|
visits_hourly_fact_y2014m08.tenant_dimension_id,
|
212
208
|
visits_hourly_fact_y2014m08.user_dimension_id,
|
213
209
|
visits_hourly_fact_y2014m08.user_agent_type_id,
|
214
210
|
visits_hourly_fact_y2014m08.feature_type_id,
|
215
211
|
SUM(visits_hourly_fact_y2014m08.total),
|
216
|
-
(
|
212
|
+
extract(EPOCH from visits_hourly_fact_y2014m08.date_dimension_id::text::date)
|
217
213
|
FROM
|
218
214
|
visits_hourly_fact_y2014m08
|
219
|
-
JOIN
|
220
|
-
date_dimension
|
221
|
-
ON
|
222
|
-
date_dimension.id = visits_hourly_fact_y2014m08.date_dimension_id
|
223
215
|
GROUP BY
|
224
|
-
|
216
|
+
visits_hourly_fact_y2014m08.date_dimension_id,
|
225
217
|
visits_hourly_fact_y2014m08.tenant_dimension_id,
|
226
218
|
visits_hourly_fact_y2014m08.user_dimension_id,
|
227
219
|
visits_hourly_fact_y2014m08.user_agent_type_id,
|
228
|
-
visits_hourly_fact_y2014m08.feature_type_id
|
220
|
+
visits_hourly_fact_y2014m08.feature_type_id,
|
221
|
+
extract(EPOCH from visits_hourly_fact_y2014m08.date_dimension_id::text::date)
|
229
222
|
;
|
230
223
|
|
231
224
|
COMMIT;
|
@@ -309,25 +302,22 @@ describe Masamune::Transform::RollupFact do
|
|
309
302
|
INSERT INTO
|
310
303
|
visits_monthly_fact_y2014m08_stage (date_dimension_id, tenant_dimension_id, user_dimension_id, user_agent_type_id, feature_type_id, total, time_key)
|
311
304
|
SELECT
|
312
|
-
(
|
305
|
+
to_char(date_trunc('month',visits_daily_fact_y2014m08.date_dimension_id::text::date),'YYYYMMDD')::integer,
|
313
306
|
visits_daily_fact_y2014m08.tenant_dimension_id,
|
314
307
|
visits_daily_fact_y2014m08.user_dimension_id,
|
315
308
|
visits_daily_fact_y2014m08.user_agent_type_id,
|
316
309
|
visits_daily_fact_y2014m08.feature_type_id,
|
317
310
|
SUM(visits_daily_fact_y2014m08.total),
|
318
|
-
(
|
311
|
+
extract(EPOCH from date_trunc('month',visits_daily_fact_y2014m08.date_dimension_id::text::date))
|
319
312
|
FROM
|
320
313
|
visits_daily_fact_y2014m08
|
321
|
-
JOIN
|
322
|
-
date_dimension
|
323
|
-
ON
|
324
|
-
date_dimension.id = visits_daily_fact_y2014m08.date_dimension_id
|
325
314
|
GROUP BY
|
326
|
-
|
315
|
+
to_char(date_trunc('month',visits_daily_fact_y2014m08.date_dimension_id::text::date),'YYYYMMDD')::integer,
|
327
316
|
visits_daily_fact_y2014m08.tenant_dimension_id,
|
328
317
|
visits_daily_fact_y2014m08.user_dimension_id,
|
329
318
|
visits_daily_fact_y2014m08.user_agent_type_id,
|
330
|
-
visits_daily_fact_y2014m08.feature_type_id
|
319
|
+
visits_daily_fact_y2014m08.feature_type_id,
|
320
|
+
extract(EPOCH from date_trunc('month',visits_daily_fact_y2014m08.date_dimension_id::text::date))
|
331
321
|
;
|
332
322
|
|
333
323
|
COMMIT;
|
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.4
|
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-10-
|
11
|
+
date: 2015-10-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: thor
|