Skip to content

Commit b7776aa

Browse files
committed
chore(cubesql): PowerBI min max test
1 parent ac2cc17 commit b7776aa

File tree

5 files changed

+44
-6
lines changed

5 files changed

+44
-6
lines changed

packages/cubejs-backend-shared/src/env.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1544,7 +1544,7 @@ const variables: Record<string, (...args: any) => any> = {
15441544
.default('5000')
15451545
.asInt(),
15461546
allowUngroupedWithoutPrimaryKey: () => get('CUBEJS_ALLOW_UNGROUPED_WITHOUT_PRIMARY_KEY')
1547-
.default('false')
1547+
.default(get('CUBESQL_SQL_PUSH_DOWN').default('false').asString())
15481548
.asBoolStrict(),
15491549
redisPassword: () => {
15501550
const redisPassword = get('CUBEJS_REDIS_PASSWORD')

packages/cubejs-testing/birdbox-fixtures/postgresql/schema/Orders.js

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
cube(`Orders`, {
22
sql: `
3-
select 1 as id, 100 as amount, 'new' status
3+
select 1 as id, 100 as amount, 'new' status, '2024-01-01'::timestamptz created_at
44
UNION ALL
5-
select 2 as id, 200 as amount, 'new' status
5+
select 2 as id, 200 as amount, 'new' status, '2024-01-02'::timestamptz created_at
66
UNION ALL
7-
select 3 as id, 300 as amount, 'processed' status
7+
select 3 as id, 300 as amount, 'processed' status, '2024-01-03'::timestamptz created_at
88
UNION ALL
9-
select 4 as id, 500 as amount, 'processed' status
9+
select 4 as id, 500 as amount, 'processed' status, '2024-01-04'::timestamptz created_at
1010
UNION ALL
11-
select 5 as id, 600 as amount, 'shipped' status
11+
select 5 as id, 600 as amount, 'shipped' status, '2024-01-05'::timestamptz created_at
1212
`,
1313
measures: {
1414
count: {
@@ -23,9 +23,20 @@ cube(`Orders`, {
2323
},
2424
},
2525
dimensions: {
26+
id: {
27+
sql: `id`,
28+
type: `number`,
29+
primaryKey: true,
30+
},
31+
2632
status: {
2733
sql: `status`,
2834
type: `string`,
2935
},
36+
37+
createdAt: {
38+
sql: `created_at`,
39+
type: `time`
40+
}
3041
},
3142
});

packages/cubejs-testing/birdbox-fixtures/postgresql/schema/SecurityContextTest.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ cube(`SecurityContextTest`, {
2020
uid: {
2121
sql: `uid`,
2222
type: `string`,
23+
primaryKey: true,
2324
},
2425
},
2526
});

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

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,3 +16,12 @@ Array [
1616
},
1717
]
1818
`;
19+
20+
exports[`SQL API Postgres (Data) powerbi min max push down: powerbi_min_max_push_down 1`] = `
21+
Array [
22+
Object {
23+
"a0": 2024-01-05T00:00:00.000Z,
24+
"a1": 2024-01-01T00:00:00.000Z,
25+
},
26+
]
27+
`;

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

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ describe('SQL API', () => {
6161
CUBEJS_DB_PASS: 'test',
6262
//
6363
CUBEJS_PG_SQL_PORT: `${pgPort}`,
64+
CUBESQL_SQL_PUSH_DOWN: 'true',
6465
},
6566
{
6667
schemaDir: 'postgresql/schema',
@@ -163,5 +164,21 @@ describe('SQL API', () => {
163164
const res = await connection.query('SELECT COUNT(*) as cn, "status" FROM Orders GROUP BY 2 ORDER BY cn DESC');
164165
expect(res.rows).toMatchSnapshot('sql_orders');
165166
});
167+
168+
test('powerbi min max push down', async () => {
169+
const res = await connection.query(`
170+
select
171+
max("rows"."createdAt") as "a0",
172+
min("rows"."createdAt") as "a1"
173+
from
174+
(
175+
select
176+
"createdAt"
177+
from
178+
"public"."Orders" "$Table"
179+
) "rows"
180+
`);
181+
expect(res.rows).toMatchSnapshot('powerbi_min_max_push_down');
182+
});
166183
});
167184
});

0 commit comments

Comments
 (0)