Skip to content

Commit 338ecb2

Browse files
committed
update
1 parent 0e2b45b commit 338ecb2

File tree

1 file changed

+32
-7
lines changed

1 file changed

+32
-7
lines changed

packages/cubejs-schema-compiler/test/integration/postgres/multi-stage.test.ts

Lines changed: 32 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,15 @@ describe('Multi-Stage', () => {
1212
cubes:
1313
- name: orders
1414
sql: >
15-
SELECT 10 as ID, 'complited' as STATUS, '2024-01-12T20:00:00.000Z'::timestamptz as CREATED_AT
15+
SELECT 9 as ID, 'completed' as STATUS, '2022-01-12T20:00:00.000Z'::timestamptz as CREATED_AT
16+
union all
17+
SELECT 10 as ID, 'completed' as STATUS, '2023-01-12T20:00:00.000Z'::timestamptz as CREATED_AT
18+
union all
19+
SELECT 11 as ID, 'completed' as STATUS, '2024-01-14T20:00:00.000Z'::timestamptz as CREATED_AT
20+
union all
21+
SELECT 12 as ID, 'completed' as STATUS, '2024-02-14T20:00:00.000Z'::timestamptz as CREATED_AT
22+
union all
23+
SELECT 13 as ID, 'completed' as STATUS, '2025-03-14T20:00:00.000Z'::timestamptz as CREATED_AT
1624
joins:
1725
- name: line_items
1826
sql: "{CUBE}.ID = {line_items}.order_id"
@@ -91,7 +99,19 @@ cubes:
9199
92100
- name: line_items
93101
sql: >
102+
SELECT 9 as ID, '2024-01-12T20:00:00.000Z'::timestamptz as CREATED_AT, 9 as ORDER_ID, 11 as PRODUCT_ID
103+
union all
94104
SELECT 10 as ID, '2024-01-12T20:00:00.000Z'::timestamptz as CREATED_AT, 10 as ORDER_ID, 10 as PRODUCT_ID
105+
union all
106+
SELECT 11 as ID, '2024-01-12T20:00:00.000Z'::timestamptz as CREATED_AT, 10 as ORDER_ID, 11 as PRODUCT_ID
107+
union all
108+
SELECT 12 as ID, '2024-01-12T20:00:00.000Z'::timestamptz as CREATED_AT, 11 as ORDER_ID, 10 as PRODUCT_ID
109+
union all
110+
SELECT 13 as ID, '2024-01-12T20:00:00.000Z'::timestamptz as CREATED_AT, 11 as ORDER_ID, 10 as PRODUCT_ID
111+
union all
112+
SELECT 14 as ID, '2024-01-12T20:00:00.000Z'::timestamptz as CREATED_AT, 12 as ORDER_ID, 10 as PRODUCT_ID
113+
union all
114+
SELECT 15 as ID, '2024-01-12T20:00:00.000Z'::timestamptz as CREATED_AT, 13 as ORDER_ID, 11 as PRODUCT_ID
95115
public: false
96116
97117
joins:
@@ -124,6 +144,8 @@ cubes:
124144
- name: products
125145
sql: >
126146
SELECT 10 as ID, 'some category' as PRODUCT_CATEGORY, 'some name' as NAME, 10 as PRICE
147+
union all
148+
SELECT 11 as ID, 'some category' as PRODUCT_CATEGORY, 'some name' as NAME, 5 as PRICE
127149
public: false
128150
description: >
129151
Products and categories in our e-commerce store.
@@ -185,17 +207,20 @@ views:
185207
}
186208

187209
it('multi stage over sub query', async () => runQueryTest({
188-
measures: ['orders.revenue', 'orders.revenue_1_y_ago'],
210+
measures: ['orders.revenue', 'orders.revenue_1_y_ago', 'orders.cagr_1_y'],
189211
timeDimensions: [
190212
{
191213
dimension: 'orders.date',
192214
granularity: 'year'
193215
}
194216
],
195-
dimensions: [
196-
'orders.status',
197-
'orders.amount'
198-
],
199217
timezone: 'UTC'
200-
}, []));
218+
}, [
219+
220+
{ orders__date_year: '2023-01-01T00:00:00.000Z',
221+
orders__revenue: '15',
222+
orders__revenue_1_y_ago: '5',
223+
orders__cagr_1_y: '2.0000000000000000' },
224+
{ orders__date_year: '2024-01-01T00:00:00.000Z', orders__revenue: '30', orders__revenue_1_y_ago: '15', orders__cagr_1_y: '1.0000000000000000' },
225+
{ orders__date_year: '2025-01-01T00:00:00.000Z', orders__revenue: '5', orders__revenue_1_y_ago: '30', orders__cagr_1_y: '-0.83333333333333333333' }]));
201226
});

0 commit comments

Comments
 (0)