Skip to content

Commit 1ce9a36

Browse files
committed
refactor(schema-compiler): Move join path in pre-agg tests to multiple join paths tests
1 parent 208d526 commit 1ce9a36

File tree

2 files changed

+33
-253
lines changed

2 files changed

+33
-253
lines changed

packages/cubejs-schema-compiler/test/integration/postgres/multiple-join-paths.test.ts

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,16 @@ describe('Multiple join paths', () => {
5959
type: 'sum',
6060
},
6161
},
62+
63+
preAggregations: {
64+
adex: {
65+
type: 'rollup',
66+
dimensionReferences: [a_id, CUBE.D.E.X.x_id],
67+
measureReferences: [a_sum, D.E.X.x_sum],
68+
// TODO implement and test segmentReferences
69+
// TODO implement and test timeDimensionReference
70+
},
71+
},
6272
});
6373
6474
cube('B', {
@@ -268,4 +278,27 @@ describe('Multiple join paths', () => {
268278
expect(sql).not.toMatch(/ON 'F' = 'X'/);
269279
});
270280
});
281+
282+
describe('PreAggregations join path', () => {
283+
it('should respect join path from pre-aggregation declaration', async () => {
284+
const query = new PostgresQuery({ joinGraph, cubeEvaluator, compiler }, {
285+
measures: [],
286+
dimensions: [
287+
'A.a_id'
288+
],
289+
});
290+
291+
const preAggregationsDescription: any = query.preAggregations?.preAggregationsDescription();
292+
const { loadSql } = preAggregationsDescription.find(p => p.preAggregationId === 'A.adex');
293+
294+
expect(loadSql[0]).toMatch(/ON 'A' = 'D'/);
295+
expect(loadSql[0]).toMatch(/ON 'D' = 'E'/);
296+
expect(loadSql[0]).toMatch(/ON 'E' = 'X'/);
297+
expect(loadSql[0]).not.toMatch(/ON 'A' = 'B'/);
298+
expect(loadSql[0]).not.toMatch(/ON 'B' = 'C'/);
299+
expect(loadSql[0]).not.toMatch(/ON 'C' = 'X'/);
300+
expect(loadSql[0]).not.toMatch(/ON 'A' = 'F'/);
301+
expect(loadSql[0]).not.toMatch(/ON 'F' = 'X'/);
302+
});
303+
});
271304
});

packages/cubejs-schema-compiler/test/integration/postgres/pre-aggregations-join-path.test.ts

Lines changed: 0 additions & 253 deletions
This file was deleted.

0 commit comments

Comments
 (0)