masamune 0.17.8 → 0.17.9

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: 9e840599bbad6c65fa1f7c4a6df934bcb1c3a35c
4
- data.tar.gz: 1b2628551fc6d1ab3001084067c0b9e4a3ed2acc
3
+ metadata.gz: c4d0b9b01db4986e5e1e5e0ef9c46164706fa099
4
+ data.tar.gz: cd49512890e210babbed05ae54ced2af962e0a26
5
5
  SHA512:
6
- metadata.gz: 6cc39b250d065e9dc2c99734d6e54cc2cc91c9ac44b929ef1173df9062642d1bf9367f5e63d90749d7da11b0b8f5fe2a0ad3b79394623d3afca4c69e3a4c357e
7
- data.tar.gz: f89b374c5ba7ed50549aea63c3933e5276029b323d7f6f75aa8cbd532f33170ad8651512c829e844095e74d61c3a4b23ff9269f9a6088b40b549bd2841d5ced6
6
+ metadata.gz: 3c67bdd84b95cbfdf0f23e5a9ef182382a4e35942f4232f0c240d52901e21e58646ecba734e1ddddabfac2fadf74150a243a0b00ef371b7b47681cb6c48518e8
7
+ data.tar.gz: 43a0b9949432131a079c3195b580cd1ed0afad6d7588cf592024b0b4e44cd89980bd2bbf02c72fefbbb15f915c95849b42a7f79d787d376704ef1bcd440c2c18
@@ -32,7 +32,7 @@ WITH ranges AS (
32
32
  FROM <%= source.name %>
33
33
  ), windows AS (
34
34
  SELECT *,
35
- SUM(r) OVER (ORDER BY <%= target.window("start_at #{order}", 'delta', 'source_uuid').join(', ') %>) window_id
35
+ SUM(r) OVER (ORDER BY <%= target.window("start_at #{order}", 'delta', 'source_uuid DESC').join(', ') %>) window_id
36
36
  FROM ranges
37
37
  ), snapshot AS (
38
38
  SELECT
@@ -21,5 +21,5 @@
21
21
  # THE SOFTWARE.
22
22
 
23
23
  module Masamune
24
- VERSION = '0.17.8'
24
+ VERSION = '0.17.9'
25
25
  end
@@ -39,8 +39,8 @@ describe Masamune::Transform::SnapshotDimension do
39
39
 
40
40
  let(:target) { catalog.postgres.user_dimension }
41
41
 
42
- context 'with postgres dimension' do
43
- subject(:result) { transform.snapshot_dimension(target.ledger_table, target.stage_table).to_s }
42
+ context 'with postgres dimension forward snapshot' do
43
+ subject(:result) { transform.snapshot_dimension(target.ledger_table, target.stage_table, 'ASC').to_s }
44
44
 
45
45
  it 'should eq render snapshot_dimension template' do
46
46
  is_expected.to eq <<-EOS.strip_heredoc
@@ -51,7 +51,60 @@ describe Masamune::Transform::SnapshotDimension do
51
51
  FROM user_dimension_ledger
52
52
  ), windows AS (
53
53
  SELECT *,
54
- SUM(r) OVER (ORDER BY tenant_id, user_id, start_at DESC, delta, source_uuid) window_id
54
+ SUM(r) OVER (ORDER BY tenant_id, user_id, start_at ASC, delta, source_uuid DESC) window_id
55
+ FROM ranges
56
+ ), snapshot AS (
57
+ SELECT
58
+ consolidated.user_account_state_type_id,
59
+ consolidated.tenant_id,
60
+ consolidated.user_id,
61
+ consolidated.preferences,
62
+ consolidated.start_at
63
+ FROM (
64
+ SELECT DISTINCT ON (tenant_id, user_id, start_at, id)
65
+ coalesce_merge(user_account_state_type_id) OVER w AS user_account_state_type_id,
66
+ tenant_id AS tenant_id,
67
+ user_id AS user_id,
68
+ hstore_merge(preferences) OVER w AS preferences,
69
+ start_at AS start_at
70
+ FROM
71
+ windows
72
+ WINDOW w AS (PARTITION BY tenant_id, user_id, window_id ORDER BY start_at ASC)
73
+ ORDER BY tenant_id, user_id, start_at ASC, id DESC, window_id
74
+ ) consolidated
75
+ WHERE
76
+ consolidated.user_account_state_type_id IS NOT NULL AND
77
+ consolidated.tenant_id IS NOT NULL AND
78
+ consolidated.user_id IS NOT NULL
79
+ )
80
+ INSERT INTO
81
+ user_dimension_stage (user_account_state_type_id, tenant_id, user_id, preferences, start_at)
82
+ SELECT
83
+ user_account_state_type_id,
84
+ tenant_id,
85
+ user_id,
86
+ preferences,
87
+ start_at
88
+ FROM
89
+ snapshot
90
+ ;
91
+ EOS
92
+ end
93
+ end
94
+
95
+ context 'with postgres dimension reverse snapshot' do
96
+ subject(:result) { transform.snapshot_dimension(target.ledger_table, target.stage_table, 'DESC').to_s }
97
+
98
+ it 'should eq render snapshot_dimension template' do
99
+ is_expected.to eq <<-EOS.strip_heredoc
100
+ WITH ranges AS (
101
+ SELECT *,
102
+ CASE WHEN delta = 0
103
+ THEN 1 ELSE NULL END r
104
+ FROM user_dimension_ledger
105
+ ), windows AS (
106
+ SELECT *,
107
+ SUM(r) OVER (ORDER BY tenant_id, user_id, start_at DESC, delta, source_uuid DESC) window_id
55
108
  FROM ranges
56
109
  ), snapshot AS (
57
110
  SELECT
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.17.8
4
+ version: 0.17.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - Michael Andrews
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-03-24 00:00:00.000000000 Z
11
+ date: 2016-03-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: thor