Skip to content

Commit 9fd3732

Browse files
committed
enable view join tests for tesseract
1 parent caf266f commit 9fd3732

File tree

1 file changed

+101
-0
lines changed

1 file changed

+101
-0
lines changed

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

Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,107 @@ view(\`V\`, {
121121
);
122122

123123
if (getEnv('nativeSqlPlanner')) {
124+
it('correct join for simple cube B dimension', async () => {
125+
const [sql, _params] = await dbRunner.runQueryTest({
126+
dimensions: ['B.ActivityBalance'],
127+
timeDimensions: [],
128+
segments: [],
129+
filters: [],
130+
}, [{
131+
b__activity_balance: 125,
132+
}], { compiler, joinGraph, cubeEvaluator });
133+
134+
expect(sql).toMatch(/AS "b"/);
135+
expect(sql).toMatch(/AS "d"/);
136+
expect(sql).toMatch(/ON "b".id = "d".id/);
137+
expect(sql).not.toMatch(/AS "a"/);
138+
expect(sql).not.toMatch(/AS "e"/);
139+
expect(sql).not.toMatch(/AS "c"/);
140+
});
141+
142+
it('correct join for simple view B-dimension', async () => {
143+
const [sql, _params] = await dbRunner.runQueryTest({
144+
dimensions: ['V.ActivityBalance'],
145+
timeDimensions: [],
146+
segments: [],
147+
filters: [],
148+
}, [{
149+
v__activity_balance: 125,
150+
}], { compiler, joinGraph, cubeEvaluator });
151+
152+
expect(sql).toMatch(/AS "a"/);
153+
expect(sql).toMatch(/AS "b"/);
154+
expect(sql).toMatch(/AS "d"/);
155+
expect(sql).toMatch(/ON "a".id = "b".id/);
156+
expect(sql).toMatch(/ON "b".id = "d".id/);
157+
expect(sql).not.toMatch(/AS "e"/);
158+
});
159+
160+
it('correct join for simple view F-dimension', async () => {
161+
const [sql, _params] = await dbRunner.runQueryTest({
162+
dimensions: ['V.PlanCode'],
163+
timeDimensions: [],
164+
segments: [],
165+
filters: [],
166+
}, [{
167+
v__plan_code: 'PLAN_CODE',
168+
}], { compiler, joinGraph, cubeEvaluator });
169+
170+
expect(sql).toMatch(/AS "a"/);
171+
expect(sql).toMatch(/AS "c"/);
172+
expect(sql).toMatch(/AS "f"/);
173+
expect(sql).toMatch(/ON "a".id = "c".id/);
174+
expect(sql).toMatch(/ON "c".plan_id = "f".plan_id/);
175+
expect(sql).not.toMatch(/AS "b"/);
176+
expect(sql).not.toMatch(/AS "d"/);
177+
expect(sql).not.toMatch(/AS "e"/);
178+
});
179+
180+
it('correct join for view F-dimension + B-dimension', async () => {
181+
const [sql, _params] = await dbRunner.runQueryTest({
182+
dimensions: ['V.PlanCode', 'V.ActivityBalance'],
183+
timeDimensions: [],
184+
segments: [],
185+
filters: [],
186+
}, [{
187+
v__plan_code: 'PLAN_CODE',
188+
v__activity_balance: 125,
189+
}], { compiler, joinGraph, cubeEvaluator });
190+
191+
expect(sql).toMatch(/AS "a"/);
192+
expect(sql).toMatch(/AS "c"/);
193+
expect(sql).toMatch(/AS "f"/);
194+
expect(sql).toMatch(/AS "b"/);
195+
expect(sql).toMatch(/AS "d"/);
196+
expect(sql).toMatch(/ON "a".id = "c".id/);
197+
expect(sql).toMatch(/ON "a".id = "b".id/);
198+
expect(sql).toMatch(/ON "c".plan_id = "f".plan_id/);
199+
expect(sql).toMatch(/ON "b".id = "d".id/);
200+
expect(sql).not.toMatch(/AS "e"/);
201+
});
202+
203+
it('correct join for view B-dimension + F-dimension', async () => {
204+
const [sql, _params] = await dbRunner.runQueryTest({
205+
dimensions: ['V.ActivityBalance', 'V.PlanCode'],
206+
timeDimensions: [],
207+
segments: [],
208+
filters: [],
209+
}, [{
210+
v__activity_balance: 125,
211+
v__plan_code: 'PLAN_CODE',
212+
}], { compiler, joinGraph, cubeEvaluator });
213+
214+
expect(sql).toMatch(/AS "a"/);
215+
expect(sql).toMatch(/AS "c"/);
216+
expect(sql).toMatch(/AS "f"/);
217+
expect(sql).toMatch(/AS "b"/);
218+
expect(sql).toMatch(/AS "d"/);
219+
expect(sql).toMatch(/ON "a".id = "c".id/);
220+
expect(sql).toMatch(/ON "a".id = "b".id/);
221+
expect(sql).toMatch(/ON "c".plan_id = "f".plan_id/);
222+
expect(sql).toMatch(/ON "b".id = "d".id/);
223+
expect(sql).not.toMatch(/AS "e"/);
224+
});
124225
} else {
125226
it('correct join for simple cube B dimension', async () => {
126227
const [sql, _params] = await dbRunner.runQueryTest({

0 commit comments

Comments
 (0)