@cubejs-backend/testing 1.7.28 → 1.7.30

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,33 @@
1
+ // Sales dollars, pre-aggregated to day/item/location in the warehouse. The
2
+ // numerator of AOV. West totals 100, East totals 60.
3
+ cube(`ItemLocationSales`, {
4
+ sql: `
5
+ select 1 as id, 1 as location_id, 30 as sales_amount
6
+ UNION ALL
7
+ select 2 as id, 1 as location_id, 70 as sales_amount
8
+ UNION ALL
9
+ select 3 as id, 2 as location_id, 60 as sales_amount
10
+ `,
11
+
12
+ joins: {
13
+ Locations: {
14
+ sql: `${CUBE}.location_id = ${Locations}.id`,
15
+ relationship: `many_to_one`,
16
+ },
17
+ },
18
+
19
+ dimensions: {
20
+ id: {
21
+ sql: `id`,
22
+ type: `number`,
23
+ primaryKey: true,
24
+ },
25
+ },
26
+
27
+ measures: {
28
+ salesAmount: {
29
+ sql: `sales_amount`,
30
+ type: `sum`,
31
+ },
32
+ },
33
+ });
@@ -0,0 +1,21 @@
1
+ // Shared dimension cube. Both facts join to it, which is what gives a
2
+ // multi-fact query something to stitch the two aggregates on.
3
+ cube(`Locations`, {
4
+ sql: `
5
+ select 1 as id, 'West' as region
6
+ UNION ALL
7
+ select 2 as id, 'East' as region
8
+ `,
9
+
10
+ dimensions: {
11
+ id: {
12
+ sql: `id`,
13
+ type: `number`,
14
+ primaryKey: true,
15
+ },
16
+ region: {
17
+ sql: `region`,
18
+ type: `string`,
19
+ },
20
+ },
21
+ });
@@ -0,0 +1,26 @@
1
+ // The same ratio owned by the view instead, alongside the cube-owned one, so
2
+ // both placements are exercised against a real database.
3
+ view(`RetailAnalysis`, {
4
+ cubes: [
5
+ {
6
+ joinPath: ItemLocationSales,
7
+ includes: [`salesAmount`],
8
+ },
9
+ {
10
+ joinPath: SalesLineItem,
11
+ includes: [`transactionsWithoutReturns`, { name: `aovBasket`, alias: `aovBasketFromCube` }],
12
+ },
13
+ {
14
+ joinPath: Locations,
15
+ includes: [`region`],
16
+ },
17
+ ],
18
+
19
+ measures: {
20
+ aovBasket: {
21
+ sql: `${CUBE.salesAmount} / NULLIF(${CUBE.transactionsWithoutReturns}, 0)`,
22
+ type: `number`,
23
+ multiStage: true,
24
+ },
25
+ },
26
+ });
@@ -0,0 +1,61 @@
1
+ // Transaction lines - a finer grain than ItemLocationSales, and no join
2
+ // between the two. The denominator of AOV counts distinct transactions, so
3
+ // West's three lines on T100 must still count as one.
4
+ //
5
+ // West: T100 (3 lines) + T101 (1 line) -> 2 transactions
6
+ // East: T200 counts, T201 is an EXCHANGE, T202 is ONLINE -> 1 transaction
7
+ //
8
+ // T201 and T202 are excluded by a different one of the measure's two filters,
9
+ // so neither predicate can be dropped without moving East's denominator.
10
+ cube(`SalesLineItem`, {
11
+ sql: `
12
+ select 1 as id, 100 as transaction_id, 1 as location_id, 'SALE' as transaction_type, 'IN_STORE' as fulfillment_channel_group
13
+ UNION ALL
14
+ select 2 as id, 100 as transaction_id, 1 as location_id, 'SALE' as transaction_type, 'IN_STORE' as fulfillment_channel_group
15
+ UNION ALL
16
+ select 3 as id, 100 as transaction_id, 1 as location_id, 'SALE' as transaction_type, 'IN_STORE' as fulfillment_channel_group
17
+ UNION ALL
18
+ select 4 as id, 101 as transaction_id, 1 as location_id, 'SALE' as transaction_type, 'IN_STORE' as fulfillment_channel_group
19
+ UNION ALL
20
+ select 5 as id, 200 as transaction_id, 2 as location_id, 'SALE' as transaction_type, 'IN_STORE' as fulfillment_channel_group
21
+ UNION ALL
22
+ select 6 as id, 201 as transaction_id, 2 as location_id, 'EXCHANGE' as transaction_type, 'IN_STORE' as fulfillment_channel_group
23
+ UNION ALL
24
+ select 7 as id, 202 as transaction_id, 2 as location_id, 'SALE' as transaction_type, 'ONLINE' as fulfillment_channel_group
25
+ `,
26
+
27
+ joins: {
28
+ Locations: {
29
+ sql: `${CUBE}.location_id = ${Locations}.id`,
30
+ relationship: `many_to_one`,
31
+ },
32
+ },
33
+
34
+ dimensions: {
35
+ id: {
36
+ sql: `id`,
37
+ type: `number`,
38
+ primaryKey: true,
39
+ },
40
+ },
41
+
42
+ measures: {
43
+ // The filter logic lives here, on the cube that owns the columns, so every
44
+ // consumer picks it up by including the measure.
45
+ transactionsWithoutReturns: {
46
+ sql: `transaction_id`,
47
+ type: `countDistinct`,
48
+ filters: [
49
+ { sql: `${CUBE}.transaction_type <> 'EXCHANGE'` },
50
+ { sql: `${CUBE}.fulfillment_channel_group IN ('IN_STORE', 'SHIP_FROM_STORE')` },
51
+ ],
52
+ },
53
+
54
+ // AOV owned by this cube, referencing the other fact's measure.
55
+ aovBasket: {
56
+ sql: `${ItemLocationSales.salesAmount} / NULLIF(${CUBE.transactionsWithoutReturns}, 0)`,
57
+ type: `number`,
58
+ multiStage: true,
59
+ },
60
+ },
61
+ });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cubejs-backend/testing",
3
- "version": "1.7.28",
3
+ "version": "1.7.30",
4
4
  "description": "Cube.js e2e tests",
5
5
  "author": "Cube Dev, Inc.",
6
6
  "repository": {
@@ -84,6 +84,7 @@
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
86
  "smoke:view-groups": "jest --verbose --forceExit -i dist/test/smoke-view-groups.test.js",
87
+ "smoke:multi-fact": "jest --verbose --forceExit -i dist/test/smoke-multi-fact.test.js",
87
88
  "smoke:shared-calc-group": "TZ=UTC jest --verbose -i dist/test/smoke-shared-calc-group.test.js"
88
89
  },
89
90
  "files": [
@@ -91,15 +92,15 @@
91
92
  "birdbox-fixtures"
92
93
  ],
93
94
  "dependencies": {
94
- "@cubejs-backend/cubestore-driver": "1.7.28",
95
+ "@cubejs-backend/cubestore-driver": "1.7.30",
95
96
  "@cubejs-backend/dotenv": "^9.0.2",
96
- "@cubejs-backend/ksql-driver": "1.7.28",
97
- "@cubejs-backend/postgres-driver": "1.7.28",
98
- "@cubejs-backend/query-orchestrator": "1.7.28",
99
- "@cubejs-backend/schema-compiler": "1.7.28",
100
- "@cubejs-backend/shared": "1.7.28",
101
- "@cubejs-backend/testing-shared": "1.7.28",
102
- "@cubejs-client/ws-transport": "1.7.28",
97
+ "@cubejs-backend/ksql-driver": "1.7.30",
98
+ "@cubejs-backend/postgres-driver": "1.7.30",
99
+ "@cubejs-backend/query-orchestrator": "1.7.30",
100
+ "@cubejs-backend/schema-compiler": "1.7.30",
101
+ "@cubejs-backend/shared": "1.7.30",
102
+ "@cubejs-backend/testing-shared": "1.7.30",
103
+ "@cubejs-client/ws-transport": "1.7.30",
103
104
  "dedent": "^0.7.0",
104
105
  "fs-extra": "^8.1.0",
105
106
  "http-proxy": "^1.18.1",
@@ -110,8 +111,8 @@
110
111
  },
111
112
  "devDependencies": {
112
113
  "@4tw/cypress-drag-drop": "^1.6.0",
113
- "@cubejs-backend/linter": "1.7.28",
114
- "@cubejs-client/core": "1.7.28",
114
+ "@cubejs-backend/linter": "1.7.30",
115
+ "@cubejs-client/core": "1.7.30",
115
116
  "@jest/globals": "^29",
116
117
  "@types/dedent": "^0.7.0",
117
118
  "@types/http-proxy": "^1.17.5",
@@ -137,5 +138,5 @@
137
138
  "eslintConfig": {
138
139
  "extends": "../cubejs-linter"
139
140
  },
140
- "gitHead": "8785332469eb076b497ee6b2eb678d77fa8a5618"
141
+ "gitHead": "8b3d6fbc08f7b03d1fe33d1e56313c00ab16aa45"
141
142
  }