Skip to content

Commit 1c3b1b6

Browse files
committed
test: Test SQL pushdown on multidb view
1 parent eb50e41 commit 1c3b1b6

File tree

4 files changed

+58
-0
lines changed

4 files changed

+58
-0
lines changed

packages/cubejs-testing/birdbox-fixtures/multidb/schema/Products.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,3 +50,10 @@ cube(`Products`, {
5050

5151
dataSource: 'products',
5252
});
53+
54+
view(`ProductsView`, {
55+
cubes: [{
56+
joinPath: Products,
57+
includes: `*`,
58+
}]
59+
});

packages/cubejs-testing/birdbox-fixtures/multidb/schema/Suppliers.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,3 +32,10 @@ cube(`Suppliers`, {
3232

3333
dataSource: 'suppliers',
3434
});
35+
36+
view(`SuppliersView`, {
37+
cubes: [{
38+
joinPath: Suppliers,
39+
includes: `*`,
40+
}]
41+
});

packages/cubejs-testing/test/__snapshots__/smoke-multidb.test.ts.snap

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,14 @@ Array [
88
]
99
`;
1010

11+
exports[`multidb SQL pushdown queries to different data sources: ProductsView 1`] = `
12+
Array [
13+
Object {
14+
"name": "apples",
15+
},
16+
]
17+
`;
18+
1119
exports[`multidb SQL pushdown queries to different data sources: Suppliers 1`] = `
1220
Array [
1321
Object {
@@ -16,6 +24,14 @@ Array [
1624
]
1725
`;
1826

27+
exports[`multidb SQL pushdown queries to different data sources: SuppliersView 1`] = `
28+
Array [
29+
Object {
30+
"company": "Fruits Inc",
31+
},
32+
]
33+
`;
34+
1935
exports[`multidb query: query 1`] = `
2036
Array [
2137
Object {

packages/cubejs-testing/test/smoke-multidb.test.ts

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,20 @@ describe('multidb', () => {
120120
expect(res.rows).toMatchSnapshot();
121121
});
122122

123+
test('SQL pushdown queries to different data sources: ProductsView', async () => {
124+
const res = await connection.query(`
125+
SELECT
126+
name
127+
FROM
128+
ProductsView
129+
WHERE
130+
LOWER(name) = 'apples'
131+
GROUP BY
132+
1
133+
`);
134+
expect(res.rows).toMatchSnapshot();
135+
});
136+
123137
test('SQL pushdown queries to different data sources: Suppliers', async () => {
124138
const res = await connection.query(`
125139
SELECT
@@ -133,4 +147,18 @@ describe('multidb', () => {
133147
`);
134148
expect(res.rows).toMatchSnapshot();
135149
});
150+
151+
test('SQL pushdown queries to different data sources: SuppliersView', async () => {
152+
const res = await connection.query(`
153+
SELECT
154+
company
155+
FROM
156+
SuppliersView
157+
WHERE
158+
LOWER(company) = 'fruits inc'
159+
GROUP BY
160+
1
161+
`);
162+
expect(res.rows).toMatchSnapshot();
163+
});
136164
});

0 commit comments

Comments
 (0)