Skip to content

Commit b3d23e5

Browse files
committed
Add tests
1 parent dad3057 commit b3d23e5

24 files changed

+1014
-0
lines changed

packages/cubejs-testing-drivers/fixtures/_schemas.json

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,16 @@
197197
"sql": "quantity",
198198
"type": "sum"
199199
},
200+
{
201+
"name": "totalQuantityPriorMonth",
202+
"multiStage": true,
203+
"sql": "{totalQuantity}",
204+
"type": "number",
205+
"timeShift": [{
206+
"interval": "1 month",
207+
"type": "prior"
208+
}]
209+
},
200210
{
201211
"name": "avgDiscount",
202212
"sql": "discount",

packages/cubejs-testing-drivers/src/tests/testQueries.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2025,5 +2025,19 @@ from
20252025
`);
20262026
expect(res.rows).toMatchSnapshot('nulls_first_last_sql_push_down');
20272027
});
2028+
2029+
executePg('SQL API: Timeshift measure from cube', async (connection) => {
2030+
const res = await connection.query(`
2031+
SELECT
2032+
DATE_TRUNC('month', orderDate) AS "orderDate",
2033+
MEASURE(totalQuantity) AS "totalQuantity",
2034+
MEASURE(totalQuantityPriorMonth) AS "totalQuantityPriorMonth"
2035+
FROM "ECommerce"
2036+
WHERE orderDate >= CAST('2020-01-01' AS DATE) AND orderDate < CAST('2021-01-01' AS DATE)
2037+
GROUP BY 1
2038+
ORDER BY 1 ASC NULLS FIRST;
2039+
`);
2040+
expect(res.rows).toMatchSnapshot();
2041+
});
20282042
});
20292043
}

packages/cubejs-testing-drivers/test/__snapshots__/athena-export-bucket-s3-full.test.ts.snap

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,51 @@ Array [
1414
]
1515
`;
1616

17+
exports[`Queries with the @cubejs-backend/athena-driver SQL API: Timeshift measure from cube 1`] = `
18+
Array [
19+
Object {
20+
"orderDate": 2020-02-01T00:00:00.000Z,
21+
"totalQuantity": 2,
22+
"totalQuantityPriorMonth": 6,
23+
},
24+
Object {
25+
"orderDate": 2020-03-01T00:00:00.000Z,
26+
"totalQuantity": 13,
27+
"totalQuantityPriorMonth": 2,
28+
},
29+
Object {
30+
"orderDate": 2020-04-01T00:00:00.000Z,
31+
"totalQuantity": 3,
32+
"totalQuantityPriorMonth": 13,
33+
},
34+
Object {
35+
"orderDate": 2020-05-01T00:00:00.000Z,
36+
"totalQuantity": 15,
37+
"totalQuantityPriorMonth": 3,
38+
},
39+
Object {
40+
"orderDate": 2020-06-01T00:00:00.000Z,
41+
"totalQuantity": 18,
42+
"totalQuantityPriorMonth": 15,
43+
},
44+
Object {
45+
"orderDate": 2020-10-01T00:00:00.000Z,
46+
"totalQuantity": 11,
47+
"totalQuantityPriorMonth": 27,
48+
},
49+
Object {
50+
"orderDate": 2020-11-01T00:00:00.000Z,
51+
"totalQuantity": 43,
52+
"totalQuantityPriorMonth": 11,
53+
},
54+
Object {
55+
"orderDate": 2020-12-01T00:00:00.000Z,
56+
"totalQuantity": 22,
57+
"totalQuantityPriorMonth": 43,
58+
},
59+
]
60+
`;
61+
1762
exports[`Queries with the @cubejs-backend/athena-driver SQL API: metabase count cast to float32 from push down: metabase_count_cast_to_float32_from_push_down 1`] = `
1863
Array [
1964
Object {

packages/cubejs-testing-drivers/test/__snapshots__/bigquery-export-bucket-gcs-full.test.ts.snap

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3226,6 +3226,51 @@ Array [
32263226
]
32273227
`;
32283228

3229+
exports[`Queries with the @cubejs-backend/bigquery-driver SQL API: Timeshift measure from cube 1`] = `
3230+
Array [
3231+
Object {
3232+
"orderDate": 2020-02-01T00:00:00.000Z,
3233+
"totalQuantity": 2,
3234+
"totalQuantityPriorMonth": 6,
3235+
},
3236+
Object {
3237+
"orderDate": 2020-03-01T00:00:00.000Z,
3238+
"totalQuantity": 13,
3239+
"totalQuantityPriorMonth": 2,
3240+
},
3241+
Object {
3242+
"orderDate": 2020-04-01T00:00:00.000Z,
3243+
"totalQuantity": 3,
3244+
"totalQuantityPriorMonth": 13,
3245+
},
3246+
Object {
3247+
"orderDate": 2020-05-01T00:00:00.000Z,
3248+
"totalQuantity": 15,
3249+
"totalQuantityPriorMonth": 3,
3250+
},
3251+
Object {
3252+
"orderDate": 2020-06-01T00:00:00.000Z,
3253+
"totalQuantity": 18,
3254+
"totalQuantityPriorMonth": 15,
3255+
},
3256+
Object {
3257+
"orderDate": 2020-10-01T00:00:00.000Z,
3258+
"totalQuantity": 11,
3259+
"totalQuantityPriorMonth": 27,
3260+
},
3261+
Object {
3262+
"orderDate": 2020-11-01T00:00:00.000Z,
3263+
"totalQuantity": 43,
3264+
"totalQuantityPriorMonth": 11,
3265+
},
3266+
Object {
3267+
"orderDate": 2020-12-01T00:00:00.000Z,
3268+
"totalQuantity": 22,
3269+
"totalQuantityPriorMonth": 43,
3270+
},
3271+
]
3272+
`;
3273+
32293274
exports[`Queries with the @cubejs-backend/bigquery-driver SQL API: metabase count cast to float32 from push down: metabase_count_cast_to_float32_from_push_down 1`] = `
32303275
Array [
32313276
Object {

packages/cubejs-testing-drivers/test/__snapshots__/clickhouse-export-bucket-s3-full.test.ts.snap

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1620,6 +1620,51 @@ Array [
16201620
]
16211621
`;
16221622

1623+
exports[`Queries with the @cubejs-backend/clickhouse-driver export-bucket-s3 SQL API: Timeshift measure from cube 1`] = `
1624+
Array [
1625+
Object {
1626+
"orderDate": 2020-02-01T00:00:00.000Z,
1627+
"totalQuantity": 2,
1628+
"totalQuantityPriorMonth": 6,
1629+
},
1630+
Object {
1631+
"orderDate": 2020-03-01T00:00:00.000Z,
1632+
"totalQuantity": 13,
1633+
"totalQuantityPriorMonth": 2,
1634+
},
1635+
Object {
1636+
"orderDate": 2020-04-01T00:00:00.000Z,
1637+
"totalQuantity": 3,
1638+
"totalQuantityPriorMonth": 13,
1639+
},
1640+
Object {
1641+
"orderDate": 2020-05-01T00:00:00.000Z,
1642+
"totalQuantity": 15,
1643+
"totalQuantityPriorMonth": 3,
1644+
},
1645+
Object {
1646+
"orderDate": 2020-06-01T00:00:00.000Z,
1647+
"totalQuantity": 18,
1648+
"totalQuantityPriorMonth": 15,
1649+
},
1650+
Object {
1651+
"orderDate": 2020-10-01T00:00:00.000Z,
1652+
"totalQuantity": 11,
1653+
"totalQuantityPriorMonth": 27,
1654+
},
1655+
Object {
1656+
"orderDate": 2020-11-01T00:00:00.000Z,
1657+
"totalQuantity": 43,
1658+
"totalQuantityPriorMonth": 11,
1659+
},
1660+
Object {
1661+
"orderDate": 2020-12-01T00:00:00.000Z,
1662+
"totalQuantity": 22,
1663+
"totalQuantityPriorMonth": 43,
1664+
},
1665+
]
1666+
`;
1667+
16231668
exports[`Queries with the @cubejs-backend/clickhouse-driver export-bucket-s3 SQL API: metabase count cast to float32 from push down: metabase_count_cast_to_float32_from_push_down 1`] = `
16241669
Array [
16251670
Object {

packages/cubejs-testing-drivers/test/__snapshots__/clickhouse-full.test.ts.snap

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1620,6 +1620,51 @@ Array [
16201620
]
16211621
`;
16221622

1623+
exports[`Queries with the @cubejs-backend/clickhouse-driver SQL API: Timeshift measure from cube 1`] = `
1624+
Array [
1625+
Object {
1626+
"orderDate": 2020-02-01T00:00:00.000Z,
1627+
"totalQuantity": 2,
1628+
"totalQuantityPriorMonth": 6,
1629+
},
1630+
Object {
1631+
"orderDate": 2020-03-01T00:00:00.000Z,
1632+
"totalQuantity": 13,
1633+
"totalQuantityPriorMonth": 2,
1634+
},
1635+
Object {
1636+
"orderDate": 2020-04-01T00:00:00.000Z,
1637+
"totalQuantity": 3,
1638+
"totalQuantityPriorMonth": 13,
1639+
},
1640+
Object {
1641+
"orderDate": 2020-05-01T00:00:00.000Z,
1642+
"totalQuantity": 15,
1643+
"totalQuantityPriorMonth": 3,
1644+
},
1645+
Object {
1646+
"orderDate": 2020-06-01T00:00:00.000Z,
1647+
"totalQuantity": 18,
1648+
"totalQuantityPriorMonth": 15,
1649+
},
1650+
Object {
1651+
"orderDate": 2020-10-01T00:00:00.000Z,
1652+
"totalQuantity": 11,
1653+
"totalQuantityPriorMonth": 27,
1654+
},
1655+
Object {
1656+
"orderDate": 2020-11-01T00:00:00.000Z,
1657+
"totalQuantity": 43,
1658+
"totalQuantityPriorMonth": 11,
1659+
},
1660+
Object {
1661+
"orderDate": 2020-12-01T00:00:00.000Z,
1662+
"totalQuantity": 22,
1663+
"totalQuantityPriorMonth": 43,
1664+
},
1665+
]
1666+
`;
1667+
16231668
exports[`Queries with the @cubejs-backend/clickhouse-driver SQL API: metabase count cast to float32 from push down: metabase_count_cast_to_float32_from_push_down 1`] = `
16241669
Array [
16251670
Object {

packages/cubejs-testing-drivers/test/__snapshots__/databricks-jdbc-export-bucket-azure-full.test.ts.snap

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6017,6 +6017,51 @@ Array [
60176017
]
60186018
`;
60196019

6020+
exports[`Queries with the @cubejs-backend/databricks-jdbc-driver export-bucket-azure SQL API: Timeshift measure from cube 1`] = `
6021+
Array [
6022+
Object {
6023+
"orderDate": 2020-02-01T00:00:00.000Z,
6024+
"totalQuantity": 2,
6025+
"totalQuantityPriorMonth": 6,
6026+
},
6027+
Object {
6028+
"orderDate": 2020-03-01T00:00:00.000Z,
6029+
"totalQuantity": 13,
6030+
"totalQuantityPriorMonth": 2,
6031+
},
6032+
Object {
6033+
"orderDate": 2020-04-01T00:00:00.000Z,
6034+
"totalQuantity": 3,
6035+
"totalQuantityPriorMonth": 13,
6036+
},
6037+
Object {
6038+
"orderDate": 2020-05-01T00:00:00.000Z,
6039+
"totalQuantity": 15,
6040+
"totalQuantityPriorMonth": 3,
6041+
},
6042+
Object {
6043+
"orderDate": 2020-06-01T00:00:00.000Z,
6044+
"totalQuantity": 18,
6045+
"totalQuantityPriorMonth": 15,
6046+
},
6047+
Object {
6048+
"orderDate": 2020-10-01T00:00:00.000Z,
6049+
"totalQuantity": 11,
6050+
"totalQuantityPriorMonth": 27,
6051+
},
6052+
Object {
6053+
"orderDate": 2020-11-01T00:00:00.000Z,
6054+
"totalQuantity": 43,
6055+
"totalQuantityPriorMonth": 11,
6056+
},
6057+
Object {
6058+
"orderDate": 2020-12-01T00:00:00.000Z,
6059+
"totalQuantity": 22,
6060+
"totalQuantityPriorMonth": 43,
6061+
},
6062+
]
6063+
`;
6064+
60206065
exports[`Queries with the @cubejs-backend/databricks-jdbc-driver export-bucket-azure SQL API: metabase count cast to float32 from push down: metabase_count_cast_to_float32_from_push_down 1`] = `
60216066
Array [
60226067
Object {

packages/cubejs-testing-drivers/test/__snapshots__/databricks-jdbc-export-bucket-azure-prefix-full.test.ts.snap

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6017,6 +6017,51 @@ Array [
60176017
]
60186018
`;
60196019

6020+
exports[`Queries with the @cubejs-backend/databricks-jdbc-driver export-bucket-azure-prefix SQL API: Timeshift measure from cube 1`] = `
6021+
Array [
6022+
Object {
6023+
"orderDate": 2020-02-01T00:00:00.000Z,
6024+
"totalQuantity": 2,
6025+
"totalQuantityPriorMonth": 6,
6026+
},
6027+
Object {
6028+
"orderDate": 2020-03-01T00:00:00.000Z,
6029+
"totalQuantity": 13,
6030+
"totalQuantityPriorMonth": 2,
6031+
},
6032+
Object {
6033+
"orderDate": 2020-04-01T00:00:00.000Z,
6034+
"totalQuantity": 3,
6035+
"totalQuantityPriorMonth": 13,
6036+
},
6037+
Object {
6038+
"orderDate": 2020-05-01T00:00:00.000Z,
6039+
"totalQuantity": 15,
6040+
"totalQuantityPriorMonth": 3,
6041+
},
6042+
Object {
6043+
"orderDate": 2020-06-01T00:00:00.000Z,
6044+
"totalQuantity": 18,
6045+
"totalQuantityPriorMonth": 15,
6046+
},
6047+
Object {
6048+
"orderDate": 2020-10-01T00:00:00.000Z,
6049+
"totalQuantity": 11,
6050+
"totalQuantityPriorMonth": 27,
6051+
},
6052+
Object {
6053+
"orderDate": 2020-11-01T00:00:00.000Z,
6054+
"totalQuantity": 43,
6055+
"totalQuantityPriorMonth": 11,
6056+
},
6057+
Object {
6058+
"orderDate": 2020-12-01T00:00:00.000Z,
6059+
"totalQuantity": 22,
6060+
"totalQuantityPriorMonth": 43,
6061+
},
6062+
]
6063+
`;
6064+
60206065
exports[`Queries with the @cubejs-backend/databricks-jdbc-driver export-bucket-azure-prefix SQL API: metabase count cast to float32 from push down: metabase_count_cast_to_float32_from_push_down 1`] = `
60216066
Array [
60226067
Object {

0 commit comments

Comments
 (0)