Skip to content

Commit 7694d20

Browse files
committed
add more tests
1 parent 47ff99b commit 7694d20

File tree

1 file changed

+36
-2
lines changed

1 file changed

+36
-2
lines changed

packages/cubejs-schema-compiler/test/integration/postgres/views-join-order-join-maps.test.ts

Lines changed: 36 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ view(\`View\`, {
1414
cubes: [
1515
{
1616
join_path: A,
17-
includes: ['id', 'name', 'd_name'],
17+
includes: ['id', 'name', 'c_name', 'd_name'],
1818
prefix: true,
1919
},
2020
{
@@ -88,7 +88,9 @@ cube('B', {
8888
8989
cube('C', {
9090
sql: \`
91-
SELECT 3 id, 2 as fk, 1 as fk_a, 'c'::text as "name"\`,
91+
SELECT 3 id, 2 as fk, 2 as fk_a, 'c1'::text as "name"
92+
UNION ALL
93+
SELECT 4 id, 3 as fk, 1 as fk_a, 'c2'::text as "name"\`,
9294
joins: {
9395
D: {
9496
relationship: \`many_to_one\`,
@@ -159,4 +161,36 @@ cube('D', {
159161
expect(sql).not.toMatch(/ON "a".id = "d".fk/);
160162
});
161163
}
164+
165+
if (getEnv('nativeSqlPlanner')) {
166+
it('querying A member proxied to non-leaf C', () => {
167+
// TODO: Fix in tesseract
168+
});
169+
} else {
170+
it('querying A member proxied to non-leaf C', async () => {
171+
const [sql, _params] = await dbRunner.runQueryTest({
172+
dimensions: [
173+
'View.A_id',
174+
'View.A_name',
175+
'View.A_c_name',
176+
],
177+
timeDimensions: [],
178+
segments: [],
179+
filters: [],
180+
total: true,
181+
}, transformResultsForTesseractIfNeeded([{
182+
view___a_id: 1,
183+
view___a_name: 'a',
184+
view___a_c_name: 'c1',
185+
}]), { compiler, joinGraph, cubeEvaluator });
186+
187+
expect(sql).toMatch(/AS "b"/);
188+
expect(sql).toMatch(/AS "c"/);
189+
expect(sql).toMatch(/ON "a".id = "b".fk/);
190+
expect(sql).toMatch(/ON "b".id = "c".fk/);
191+
expect(sql).not.toMatch(/ON "c".id = "d".fk_d/);
192+
expect(sql).not.toMatch(/AS "d"/);
193+
expect(sql).not.toMatch(/ON "a".id = "c".fk_a/);
194+
});
195+
}
162196
});

0 commit comments

Comments
 (0)