@cubejs-backend/testing 1.7.8 → 1.7.11

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,7 @@
1
+ module.exports = {
2
+ orchestratorOptions: {
3
+ preAggregationsOptions: {
4
+ externalRefresh: false,
5
+ },
6
+ },
7
+ };
@@ -0,0 +1,22 @@
1
+ views:
2
+ - name: performance_view
3
+ cubes:
4
+ - join_path: sales
5
+ includes:
6
+ - account
7
+ - product
8
+ - date
9
+ - total
10
+ - rolling_amount
11
+ - rolling_amount_change
12
+ - rolling_amount_growth_pct
13
+
14
+ - join_path: share_metrics
15
+ includes:
16
+ - rolling_share_change
17
+ - name: date
18
+ alias: ms_date
19
+
20
+ - join_path: rolling_window_dim
21
+ includes:
22
+ - rolling_window
@@ -0,0 +1,19 @@
1
+ # Shared rolling-window selector (calc group): a single-row cube hosting a
2
+ # `type: switch` dimension that case entrypoint measures in several fact
3
+ # cubes dispatch on, so one filter resolves the window for all of them.
4
+ cubes:
5
+ - name: rolling_window_dim
6
+ sql: SELECT 1 AS one
7
+ public: false
8
+ dimensions:
9
+ - name: one
10
+ sql: one
11
+ type: number
12
+ primary_key: true
13
+ public: false
14
+
15
+ - name: rolling_window
16
+ type: switch
17
+ values:
18
+ - R3
19
+ - YTD
@@ -0,0 +1,175 @@
1
+ cubes:
2
+ - name: sales
3
+ sql: >
4
+ SELECT 'A1' AS account, 'P1' AS product, '2017-01-15T00:00:00.000Z'::timestamptz AS sale_date, 10.0 AS amount UNION ALL
5
+ SELECT 'A1' AS account, 'P1' AS product, '2017-02-15T00:00:00.000Z'::timestamptz AS sale_date, 20.0 AS amount UNION ALL
6
+ SELECT 'A1' AS account, 'P1' AS product, '2017-03-15T00:00:00.000Z'::timestamptz AS sale_date, 30.0 AS amount UNION ALL
7
+ SELECT 'A1' AS account, 'P1' AS product, '2017-04-15T00:00:00.000Z'::timestamptz AS sale_date, 40.0 AS amount UNION ALL
8
+ SELECT 'A1' AS account, 'P1' AS product, '2017-05-15T00:00:00.000Z'::timestamptz AS sale_date, 50.0 AS amount UNION ALL
9
+ SELECT 'A1' AS account, 'P1' AS product, '2017-06-15T00:00:00.000Z'::timestamptz AS sale_date, 60.0 AS amount UNION ALL
10
+ SELECT 'A1' AS account, 'P2' AS product, '2017-01-15T00:00:00.000Z'::timestamptz AS sale_date, 5.0 AS amount UNION ALL
11
+ SELECT 'A1' AS account, 'P2' AS product, '2017-02-15T00:00:00.000Z'::timestamptz AS sale_date, 5.0 AS amount UNION ALL
12
+ SELECT 'A1' AS account, 'P2' AS product, '2017-03-15T00:00:00.000Z'::timestamptz AS sale_date, 5.0 AS amount UNION ALL
13
+ SELECT 'A1' AS account, 'P2' AS product, '2017-04-15T00:00:00.000Z'::timestamptz AS sale_date, 5.0 AS amount UNION ALL
14
+ SELECT 'A1' AS account, 'P2' AS product, '2017-05-15T00:00:00.000Z'::timestamptz AS sale_date, 5.0 AS amount UNION ALL
15
+ SELECT 'A1' AS account, 'P2' AS product, '2017-06-15T00:00:00.000Z'::timestamptz AS sale_date, 5.0 AS amount UNION ALL
16
+ SELECT 'A2' AS account, 'P1' AS product, '2017-01-15T00:00:00.000Z'::timestamptz AS sale_date, 1.0 AS amount UNION ALL
17
+ SELECT 'A2' AS account, 'P1' AS product, '2017-02-15T00:00:00.000Z'::timestamptz AS sale_date, 1.0 AS amount UNION ALL
18
+ SELECT 'A2' AS account, 'P1' AS product, '2017-03-15T00:00:00.000Z'::timestamptz AS sale_date, 1.0 AS amount UNION ALL
19
+ SELECT 'A2' AS account, 'P1' AS product, '2017-04-15T00:00:00.000Z'::timestamptz AS sale_date, 1.0 AS amount UNION ALL
20
+ SELECT 'A2' AS account, 'P1' AS product, '2017-05-15T00:00:00.000Z'::timestamptz AS sale_date, 1.0 AS amount UNION ALL
21
+ SELECT 'A2' AS account, 'P1' AS product, '2017-06-15T00:00:00.000Z'::timestamptz AS sale_date, 1.0 AS amount
22
+ public: false
23
+
24
+ joins:
25
+ # Virtual edge to the shared rolling-window calc group cube (single
26
+ # row, 1 = 1) so the join graph connects; the switch dimension itself
27
+ # is cross-joined as a virtual values table, not via this SQL.
28
+ - name: rolling_window_dim
29
+ sql: "1 = 1"
30
+ relationship: many_to_one
31
+
32
+ dimensions:
33
+ - name: id
34
+ sql: "{CUBE}.account || '|' || {CUBE}.product || '|' || CAST({CUBE}.sale_date AS TEXT)"
35
+ type: string
36
+ primary_key: true
37
+ public: false
38
+
39
+ - name: account
40
+ sql: account
41
+ type: string
42
+
43
+ - name: product
44
+ sql: product
45
+ type: string
46
+
47
+ - name: date
48
+ sql: sale_date
49
+ type: time
50
+
51
+ measures:
52
+ - name: total
53
+ sql: amount
54
+ type: sum
55
+
56
+ - name: r3_amount
57
+ sql: amount
58
+ type: sum
59
+ public: false
60
+ rolling_window:
61
+ trailing: 3 month
62
+
63
+ - name: prev_r3_amount
64
+ multi_stage: true
65
+ sql: "{r3_amount}"
66
+ type: number
67
+ public: false
68
+ time_shift:
69
+ - interval: 3 month
70
+ type: prior
71
+
72
+ - name: r3_amount_change
73
+ multi_stage: true
74
+ type: number
75
+ public: false
76
+ sql: "({r3_amount} - {prev_r3_amount})"
77
+
78
+ - name: ytd_amount
79
+ sql: amount
80
+ type: sum
81
+ public: false
82
+ rolling_window:
83
+ type: to_date
84
+ granularity: year
85
+
86
+ - name: prev_ytd_amount
87
+ multi_stage: true
88
+ sql: "{ytd_amount}"
89
+ type: number
90
+ public: false
91
+ time_shift:
92
+ - interval: 1 year
93
+ type: prior
94
+
95
+ - name: ytd_amount_change
96
+ multi_stage: true
97
+ type: number
98
+ public: false
99
+ sql: "({ytd_amount} - {prev_ytd_amount})"
100
+
101
+ - name: r3_amount_growth_pct
102
+ multi_stage: true
103
+ type: number
104
+ public: false
105
+ format: percent
106
+ sql: >
107
+ CASE
108
+ WHEN {r3_amount} IS NULL OR {prev_r3_amount} IS NULL OR {prev_r3_amount} = 0
109
+ THEN NULL
110
+ ELSE ({r3_amount} - {prev_r3_amount}) / {prev_r3_amount}
111
+ END
112
+
113
+ - name: ytd_amount_growth_pct
114
+ multi_stage: true
115
+ type: number
116
+ public: false
117
+ format: percent
118
+ sql: >
119
+ CASE
120
+ WHEN {ytd_amount} IS NULL OR {prev_ytd_amount} IS NULL OR {prev_ytd_amount} = 0
121
+ THEN NULL
122
+ ELSE ({ytd_amount} - {prev_ytd_amount}) / {prev_ytd_amount}
123
+ END
124
+
125
+ - name: rolling_amount
126
+ multi_stage: true
127
+ type: number
128
+ case:
129
+ switch: "{rolling_window_dim.rolling_window}"
130
+ when:
131
+ - value: R3
132
+ sql: "{CUBE.r3_amount}"
133
+ else:
134
+ sql: "{CUBE.ytd_amount}"
135
+
136
+ - name: rolling_amount_change
137
+ multi_stage: true
138
+ type: number
139
+ case:
140
+ switch: "{rolling_window_dim.rolling_window}"
141
+ when:
142
+ - value: R3
143
+ sql: "{CUBE.r3_amount_change}"
144
+ else:
145
+ sql: "{CUBE.ytd_amount_change}"
146
+
147
+ - name: rolling_amount_growth_pct
148
+ multi_stage: true
149
+ type: number
150
+ format: percent
151
+ case:
152
+ switch: "{rolling_window_dim.rolling_window}"
153
+ when:
154
+ - value: R3
155
+ sql: "{CUBE.r3_amount_growth_pct}"
156
+ else:
157
+ sql: "{CUBE.ytd_amount_growth_pct}"
158
+
159
+ pre_aggregations:
160
+ - name: perf_rolling
161
+ measures:
162
+ - total
163
+ - r3_amount
164
+ - ytd_amount
165
+ # The rolling_window calc group is virtual and resolved at query
166
+ # time, so it is intentionally NOT stored in the rollup.
167
+ dimensions:
168
+ - account
169
+ - product
170
+ time_dimension: date
171
+ granularity: month
172
+ allow_non_strict_date_range_match: true
173
+ scheduled_refresh: false
174
+ refresh_key:
175
+ every: 1 hour
@@ -0,0 +1,212 @@
1
+ cubes:
2
+ - name: share_metrics
3
+ sql: >
4
+ SELECT 'A1' AS account, 'P1' AS product, 'P1' AS competitor_product, '2017-01-15T00:00:00.000Z'::timestamptz AS sale_date, 1.0 AS qty UNION ALL
5
+ SELECT 'A1' AS account, 'P1' AS product, 'P1' AS competitor_product, '2017-02-15T00:00:00.000Z'::timestamptz AS sale_date, 2.0 AS qty UNION ALL
6
+ SELECT 'A1' AS account, 'P1' AS product, 'P1' AS competitor_product, '2017-03-15T00:00:00.000Z'::timestamptz AS sale_date, 3.0 AS qty UNION ALL
7
+ SELECT 'A1' AS account, 'P1' AS product, 'P1' AS competitor_product, '2017-04-15T00:00:00.000Z'::timestamptz AS sale_date, 4.0 AS qty UNION ALL
8
+ SELECT 'A1' AS account, 'P1' AS product, 'P1' AS competitor_product, '2017-05-15T00:00:00.000Z'::timestamptz AS sale_date, 5.0 AS qty UNION ALL
9
+ SELECT 'A1' AS account, 'P1' AS product, 'P1' AS competitor_product, '2017-06-15T00:00:00.000Z'::timestamptz AS sale_date, 6.0 AS qty UNION ALL
10
+ SELECT 'A1' AS account, 'P1' AS product, 'Q' AS competitor_product, '2017-01-15T00:00:00.000Z'::timestamptz AS sale_date, 9.0 AS qty UNION ALL
11
+ SELECT 'A1' AS account, 'P1' AS product, 'Q' AS competitor_product, '2017-02-15T00:00:00.000Z'::timestamptz AS sale_date, 8.0 AS qty UNION ALL
12
+ SELECT 'A1' AS account, 'P1' AS product, 'Q' AS competitor_product, '2017-03-15T00:00:00.000Z'::timestamptz AS sale_date, 7.0 AS qty UNION ALL
13
+ SELECT 'A1' AS account, 'P1' AS product, 'Q' AS competitor_product, '2017-04-15T00:00:00.000Z'::timestamptz AS sale_date, 6.0 AS qty UNION ALL
14
+ SELECT 'A1' AS account, 'P1' AS product, 'Q' AS competitor_product, '2017-05-15T00:00:00.000Z'::timestamptz AS sale_date, 5.0 AS qty UNION ALL
15
+ SELECT 'A1' AS account, 'P1' AS product, 'Q' AS competitor_product, '2017-06-15T00:00:00.000Z'::timestamptz AS sale_date, 4.0 AS qty
16
+ public: false
17
+
18
+ joins:
19
+ # Virtual edge to the shared rolling-window calc group cube (single
20
+ # row, 1 = 1) so the join graph connects; the switch dimension itself
21
+ # is cross-joined as a virtual values table, not via this SQL.
22
+ - name: rolling_window_dim
23
+ sql: "1 = 1"
24
+ relationship: many_to_one
25
+
26
+ - name: sales
27
+ sql: "{CUBE}.account = {sales.account} AND {CUBE}.product = {sales.product} AND {CUBE}.sale_date = {sales.date}"
28
+ relationship: many_to_one
29
+
30
+ dimensions:
31
+ - name: id
32
+ sql: "{CUBE}.account || '|' || {CUBE}.product || '|' || {CUBE}.competitor_product || '|' || CAST({CUBE}.sale_date AS TEXT)"
33
+ type: string
34
+ primary_key: true
35
+ public: false
36
+
37
+ - name: account
38
+ sql: account
39
+ type: string
40
+
41
+ - name: product
42
+ sql: product
43
+ type: string
44
+
45
+ - name: competitor_product
46
+ sql: competitor_product
47
+ type: string
48
+
49
+ - name: date
50
+ sql: sale_date
51
+ type: time
52
+
53
+ measures:
54
+ - name: numerator_r3
55
+ type: sum
56
+ public: false
57
+ rolling_window:
58
+ trailing: 3 month
59
+ sql: "CASE WHEN {CUBE}.competitor_product = {CUBE}.product THEN {CUBE}.qty ELSE 0 END"
60
+
61
+ - name: denominator_r3
62
+ type: sum
63
+ public: false
64
+ rolling_window:
65
+ trailing: 3 month
66
+ sql: qty
67
+
68
+ - name: numerator_r3_new
69
+ multi_stage: true
70
+ sql: "{numerator_r3}"
71
+ type: number
72
+ public: false
73
+
74
+ - name: denominator_r3_new
75
+ multi_stage: true
76
+ sql: "{denominator_r3}"
77
+ type: number
78
+ public: false
79
+
80
+ - name: share_r3
81
+ multi_stage: true
82
+ type: number
83
+ public: false
84
+ sql: "CASE WHEN {denominator_r3_new} = 0 THEN NULL ELSE {numerator_r3_new} / {denominator_r3_new} END"
85
+
86
+ - name: prev_numerator_r3
87
+ multi_stage: true
88
+ sql: "{numerator_r3}"
89
+ type: number
90
+ public: false
91
+ time_shift:
92
+ - time_dimension: date
93
+ interval: 3 month
94
+ type: prior
95
+
96
+ - name: prev_denominator_r3
97
+ multi_stage: true
98
+ sql: "{denominator_r3}"
99
+ type: number
100
+ public: false
101
+ time_shift:
102
+ - time_dimension: date
103
+ interval: 3 month
104
+ type: prior
105
+
106
+ - name: prev_share_r3
107
+ multi_stage: true
108
+ type: number
109
+ public: false
110
+ sql: "CASE WHEN {prev_denominator_r3} = 0 THEN NULL ELSE {prev_numerator_r3} / {prev_denominator_r3} END"
111
+
112
+ - name: share_change_r3
113
+ multi_stage: true
114
+ type: number
115
+ public: false
116
+ sql: "({share_r3} - {prev_share_r3})"
117
+
118
+ - name: numerator_ytd
119
+ type: sum
120
+ public: false
121
+ rolling_window:
122
+ type: to_date
123
+ granularity: year
124
+ sql: "CASE WHEN {CUBE}.competitor_product = {CUBE}.product THEN {CUBE}.qty ELSE 0 END"
125
+
126
+ - name: denominator_ytd
127
+ type: sum
128
+ public: false
129
+ rolling_window:
130
+ type: to_date
131
+ granularity: year
132
+ sql: qty
133
+
134
+ - name: numerator_ytd_new
135
+ multi_stage: true
136
+ sql: "{numerator_ytd}"
137
+ type: number
138
+ public: false
139
+
140
+ - name: denominator_ytd_new
141
+ multi_stage: true
142
+ sql: "{denominator_ytd}"
143
+ type: number
144
+ public: false
145
+
146
+ - name: share_ytd
147
+ multi_stage: true
148
+ type: number
149
+ public: false
150
+ sql: "CASE WHEN {denominator_ytd_new} = 0 THEN NULL ELSE {numerator_ytd_new} / {denominator_ytd_new} END"
151
+
152
+ - name: prev_numerator_ytd
153
+ multi_stage: true
154
+ sql: "{numerator_ytd}"
155
+ type: number
156
+ public: false
157
+ time_shift:
158
+ - time_dimension: date
159
+ interval: 1 year
160
+ type: prior
161
+
162
+ - name: prev_denominator_ytd
163
+ multi_stage: true
164
+ sql: "{denominator_ytd}"
165
+ type: number
166
+ public: false
167
+ time_shift:
168
+ - time_dimension: date
169
+ interval: 1 year
170
+ type: prior
171
+
172
+ - name: prev_share_ytd
173
+ multi_stage: true
174
+ type: number
175
+ public: false
176
+ sql: "CASE WHEN {prev_denominator_ytd} = 0 THEN NULL ELSE {prev_numerator_ytd} / {prev_denominator_ytd} END"
177
+
178
+ - name: share_change_ytd
179
+ multi_stage: true
180
+ type: number
181
+ public: false
182
+ sql: "({share_ytd} - {prev_share_ytd})"
183
+
184
+ - name: rolling_share_change
185
+ multi_stage: true
186
+ type: number
187
+ case:
188
+ switch: "{rolling_window_dim.rolling_window}"
189
+ when:
190
+ - value: R3
191
+ sql: "{CUBE.share_change_r3}"
192
+ else:
193
+ sql: "{CUBE.share_change_ytd}"
194
+
195
+ pre_aggregations:
196
+ - name: perf_share
197
+ measures:
198
+ - numerator_r3
199
+ - denominator_r3
200
+ - numerator_ytd
201
+ - denominator_ytd
202
+ dimensions:
203
+ - account
204
+ - product
205
+ - sales.account
206
+ - sales.product
207
+ time_dimension: date
208
+ granularity: month
209
+ allow_non_strict_date_range_match: true
210
+ scheduled_refresh: false
211
+ refresh_key:
212
+ every: 1 hour
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cubejs-backend/testing",
3
- "version": "1.7.8",
3
+ "version": "1.7.11",
4
4
  "description": "Cube.js e2e tests",
5
5
  "author": "Cube Dev, Inc.",
6
6
  "repository": {
@@ -83,22 +83,23 @@
83
83
  "smoke:mssql:snapshot": "jest --verbose --forceExit --updateSnapshot -i dist/test/smoke-mssql.test.js",
84
84
  "smoke:duckdb": "jest --verbose -i dist/test/smoke-duckdb.test.js",
85
85
  "smoke:duckdb:snapshot": "jest --verbose --updateSnapshot -i dist/test/smoke-duckdb.test.js",
86
- "smoke:view-groups": "jest --verbose --forceExit -i dist/test/smoke-view-groups.test.js"
86
+ "smoke:view-groups": "jest --verbose --forceExit -i dist/test/smoke-view-groups.test.js",
87
+ "smoke:shared-calc-group": "TZ=UTC jest --verbose -i dist/test/smoke-shared-calc-group.test.js"
87
88
  },
88
89
  "files": [
89
90
  "dist/src",
90
91
  "birdbox-fixtures"
91
92
  ],
92
93
  "dependencies": {
93
- "@cubejs-backend/cubestore-driver": "1.7.8",
94
+ "@cubejs-backend/cubestore-driver": "1.7.11",
94
95
  "@cubejs-backend/dotenv": "^9.0.2",
95
- "@cubejs-backend/ksql-driver": "1.7.8",
96
- "@cubejs-backend/postgres-driver": "1.7.8",
97
- "@cubejs-backend/query-orchestrator": "1.7.8",
98
- "@cubejs-backend/schema-compiler": "1.7.8",
99
- "@cubejs-backend/shared": "1.7.8",
100
- "@cubejs-backend/testing-shared": "1.7.8",
101
- "@cubejs-client/ws-transport": "1.7.8",
96
+ "@cubejs-backend/ksql-driver": "1.7.11",
97
+ "@cubejs-backend/postgres-driver": "1.7.11",
98
+ "@cubejs-backend/query-orchestrator": "1.7.11",
99
+ "@cubejs-backend/schema-compiler": "1.7.11",
100
+ "@cubejs-backend/shared": "1.7.11",
101
+ "@cubejs-backend/testing-shared": "1.7.11",
102
+ "@cubejs-client/ws-transport": "1.7.11",
102
103
  "dedent": "^0.7.0",
103
104
  "fs-extra": "^8.1.0",
104
105
  "http-proxy": "^1.18.1",
@@ -109,8 +110,8 @@
109
110
  },
110
111
  "devDependencies": {
111
112
  "@4tw/cypress-drag-drop": "^1.6.0",
112
- "@cubejs-backend/linter": "1.7.8",
113
- "@cubejs-client/core": "1.7.8",
113
+ "@cubejs-backend/linter": "1.7.11",
114
+ "@cubejs-client/core": "1.7.11",
114
115
  "@jest/globals": "^29",
115
116
  "@types/dedent": "^0.7.0",
116
117
  "@types/http-proxy": "^1.17.5",
@@ -136,5 +137,5 @@
136
137
  "eslintConfig": {
137
138
  "extends": "../cubejs-linter"
138
139
  },
139
- "gitHead": "d020a583dbb9f0284e42801dc5b38cdbf100c0d2"
140
+ "gitHead": "911e38b02aaee9be361712e68e59a8728d643f1b"
140
141
  }