Skip to content

Commit 00c252b

Browse files
committed
trying to adopt loop test
fix actually incorrect tests
1 parent 2a59854 commit 00c252b

File tree

1 file changed

+36
-36
lines changed

1 file changed

+36
-36
lines changed

packages/cubejs-schema-compiler/test/integration/postgres/sql-generation.test.ts

Lines changed: 36 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -5198,7 +5198,7 @@ cubes:
51985198
sql: amount
51995199
type: sum
52005200
5201-
# Join loop for testing transitive joins
5201+
# Model for testing multiple joins to the same cube via transitive joins
52025202
- name: alpha_facts
52035203
sql: |
52045204
(
@@ -5256,9 +5256,9 @@ cubes:
52565256
- name: gamma_dims
52575257
sql: |
52585258
(
5259-
SELECT 10 AS b_id, 'Beta1' AS b_name
5259+
SELECT 10 AS b_id, 'Beta1' AS b_name, 'Gamma1' AS c_name
52605260
UNION ALL
5261-
SELECT 20 AS b_id, 'Beta2' AS b_name
5261+
SELECT 20 AS b_id, 'Beta2' AS b_name, 'Gamma2' AS c_name
52625262
)
52635263
dimensions:
52645264
- name: b_id
@@ -5272,16 +5272,16 @@ cubes:
52725272
- name: delta_bridge
52735273
sql: |
52745274
(
5275-
SELECT 'Alpha1' AS a_name, 'Beta1' AS b_name, 'Organic' AS channel
5275+
SELECT 'Alpha1' AS a_name, 'Beta1' AS b_name, 'Gamma1' AS c_name, 'Organic' AS channel
52765276
UNION ALL
5277-
SELECT 'Alpha1' AS a_name, 'Beta2' AS b_name, 'Paid' AS channel
5277+
SELECT 'Alpha1' AS a_name, 'Beta2' AS b_name, 'Gamma2' AS c_name, 'Paid' AS channel
52785278
UNION ALL
5279-
SELECT 'Alpha2' AS a_name, 'Beta1' AS b_name, 'Referral' AS channel
5279+
SELECT 'Alpha2' AS a_name, 'Beta1' AS b_name, 'Gamma3' AS c_name, 'Referral' AS channel
52805280
)
52815281
joins:
52825282
- name: gamma_dims
52835283
relationship: many_to_one
5284-
sql: "{CUBE}.b_name = {gamma_dims.b_name}"
5284+
sql: "{CUBE}.c_name = {gamma_dims.c_name}"
52855285
dimensions:
52865286
- name: a_name
52875287
sql: a_name
@@ -5290,7 +5290,9 @@ cubes:
52905290
- name: b_name
52915291
sql: "{gamma_dims.b_name}"
52925292
type: string
5293-
primary_key: true
5293+
- name: c_name
5294+
sql: c_name
5295+
type: string
52945296
- name: channel
52955297
sql: channel
52965298
type: string
@@ -5343,34 +5345,32 @@ cubes:
53435345
});
53445346
}
53455347

5346-
if (!getEnv('nativeSqlPlanner')) {
5347-
it('querying cube with transitive joins with loop', async () => {
5348-
await compiler.compile();
5348+
it('querying cube with transitive joins with a few joins to same cube', async () => {
5349+
// TODO: This is not supported atm, but it's a good case, so keeeping this test
5350+
// for the future implementation
5351+
5352+
// await compiler.compile();
5353+
//
5354+
// const query = new PostgresQuery({ joinGraph, cubeEvaluator, compiler }, {
5355+
// measures: [],
5356+
// dimensions: [
5357+
// 'alpha_facts.reporting_date',
5358+
// 'delta_bridge.b_name',
5359+
// 'alpha_facts.channel'
5360+
// ],
5361+
// order: [{
5362+
// id: 'alpha_facts.reporting_date'
5363+
// }],
5364+
// timezone: 'America/Los_Angeles'
5365+
// });
5366+
//
5367+
// const res = await dbRunner.testQuery(query.buildSqlAndParams());
5368+
// console.log(JSON.stringify(res));
5369+
//
5370+
// expect(res).toEqual([
5371+
// // Fill
5372+
// ]);
5373+
});
53495374

5350-
try {
5351-
const query = new PostgresQuery({ joinGraph, cubeEvaluator, compiler }, {
5352-
measures: [],
5353-
dimensions: [
5354-
'alpha_facts.reporting_date',
5355-
'delta_bridge.b_name',
5356-
'alpha_facts.channel'
5357-
],
5358-
order: [{
5359-
id: 'alpha_facts.reporting_date'
5360-
}],
5361-
timezone: 'America/Los_Angeles'
5362-
});
5363-
5364-
await dbRunner.testQuery(query.buildSqlAndParams());
5365-
throw new Error('Should have thrown an error');
5366-
} catch (err: any) {
5367-
expect(err.message).toContain('Can not construct joins for the query, potential loop detected');
5368-
}
5369-
});
5370-
} else {
5371-
it.skip('FIXME(tesseract): querying cube dimension that require transitive joins', async () => {
5372-
// FIXME should be implemented in Tesseract
5373-
});
5374-
}
53755375
});
53765376
});

0 commit comments

Comments
 (0)