Skip to content

Commit e2509c4

Browse files
committed
add drivers tests
1 parent 8f83426 commit e2509c4

File tree

1 file changed

+147
-1
lines changed

1 file changed

+147
-1
lines changed

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

Lines changed: 147 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1588,7 +1588,7 @@ export function testQueries(type: string, { includeIncrementalSchemaSuite, exten
15881588
expect(response.rawData()).toMatchSnapshot();
15891589
});
15901590

1591-
execute('querying BigECommerce: rolling window YTD', async () => {
1591+
execute('querying BigECommerce: rolling window YTD (month)', async () => {
15921592
const response = await client.load({
15931593
measures: [
15941594
'BigECommerce.rollingCountYTD',
@@ -1598,6 +1598,107 @@ export function testQueries(type: string, { includeIncrementalSchemaSuite, exten
15981598
granularity: 'month',
15991599
dateRange: ['2020-01-01', '2020-12-31'],
16001600
}],
1601+
order: [
1602+
['BigECommerce.orderDate', 'asc'],
1603+
],
1604+
});
1605+
expect(response.rawData()).toMatchSnapshot();
1606+
});
1607+
1608+
execute('querying BigECommerce: rolling window YTD (month + week)', async () => {
1609+
const response = await client.load({
1610+
measures: [
1611+
'BigECommerce.rollingCountYTD',
1612+
],
1613+
timeDimensions: [{
1614+
dimension: 'BigECommerce.orderDate',
1615+
granularity: 'month',
1616+
dateRange: ['2020-01-01', '2020-12-31'],
1617+
}, {
1618+
dimension: 'BigECommerce.orderDate',
1619+
granularity: 'week',
1620+
dateRange: ['2020-01-01', '2020-12-31'],
1621+
}],
1622+
order: [
1623+
['BigECommerce.orderDate', 'asc'],
1624+
],
1625+
});
1626+
expect(response.rawData()).toMatchSnapshot();
1627+
});
1628+
1629+
execute('querying BigECommerce: rolling window YTD (month + week + no gran)', async () => {
1630+
const response = await client.load({
1631+
measures: [
1632+
'BigECommerce.rollingCountYTD',
1633+
],
1634+
timeDimensions: [{
1635+
dimension: 'BigECommerce.orderDate',
1636+
granularity: 'month',
1637+
dateRange: ['2020-01-01', '2020-12-31'],
1638+
}, {
1639+
dimension: 'BigECommerce.orderDate',
1640+
granularity: 'week',
1641+
dateRange: ['2020-01-01', '2020-12-31'],
1642+
}, {
1643+
dimension: 'BigECommerce.orderDate',
1644+
dateRange: ['2020-01-01', '2020-12-31'],
1645+
}],
1646+
order: [
1647+
['BigECommerce.orderDate', 'asc'],
1648+
],
1649+
});
1650+
expect(response.rawData()).toMatchSnapshot();
1651+
});
1652+
1653+
execute('querying BigECommerce: rolling window YTD (month + week + day)', async () => {
1654+
const response = await client.load({
1655+
measures: [
1656+
'BigECommerce.rollingCountYTD',
1657+
],
1658+
timeDimensions: [{
1659+
dimension: 'BigECommerce.orderDate',
1660+
granularity: 'month',
1661+
dateRange: ['2020-01-01', '2020-03-01'],
1662+
}, {
1663+
dimension: 'BigECommerce.orderDate',
1664+
granularity: 'week',
1665+
dateRange: ['2020-01-01', '2020-03-01'],
1666+
}, {
1667+
dimension: 'BigECommerce.orderDate',
1668+
granularity: 'day',
1669+
dateRange: ['2020-01-01', '2020-03-01'],
1670+
}],
1671+
order: [
1672+
['BigECommerce.orderDate', 'asc'],
1673+
],
1674+
});
1675+
expect(response.rawData()).toMatchSnapshot();
1676+
});
1677+
1678+
execute('querying BigECommerce: rolling window YTD (month + week + day + no gran)', async () => {
1679+
const response = await client.load({
1680+
measures: [
1681+
'BigECommerce.rollingCountYTD',
1682+
],
1683+
timeDimensions: [{
1684+
dimension: 'BigECommerce.orderDate',
1685+
granularity: 'month',
1686+
dateRange: ['2020-01-01', '2020-03-01'],
1687+
}, {
1688+
dimension: 'BigECommerce.orderDate',
1689+
granularity: 'week',
1690+
dateRange: ['2020-01-01', '2020-03-01'],
1691+
}, {
1692+
dimension: 'BigECommerce.orderDate',
1693+
granularity: 'day',
1694+
dateRange: ['2020-01-01', '2020-03-01'],
1695+
}, {
1696+
dimension: 'BigECommerce.orderDate',
1697+
dateRange: ['2020-01-01', '2020-03-01'],
1698+
}],
1699+
order: [
1700+
['BigECommerce.orderDate', 'asc'],
1701+
],
16011702
});
16021703
expect(response.rawData()).toMatchSnapshot();
16031704
});
@@ -1615,6 +1716,19 @@ export function testQueries(type: string, { includeIncrementalSchemaSuite, exten
16151716
expect(response.rawData()).toMatchSnapshot();
16161717
});
16171718

1719+
execute('querying BigECommerce: rolling window YTD without granularity', async () => {
1720+
const response = await client.load({
1721+
measures: [
1722+
'BigECommerce.rollingCountYTD',
1723+
],
1724+
timeDimensions: [{
1725+
dimension: 'BigECommerce.orderDate',
1726+
dateRange: ['2020-01-01', '2020-03-01'],
1727+
}],
1728+
});
1729+
expect(response.rawData()).toMatchSnapshot();
1730+
});
1731+
16181732
if (includeHLLSuite) {
16191733
execute('querying BigECommerce: rolling count_distinct_approx window by 2 day', async () => {
16201734
const response = await client.load({
@@ -2102,6 +2216,38 @@ from
21022216
expect(res.rows).toMatchSnapshot();
21032217
});
21042218

2219+
executePg('SQL API: Rolling Window YTD (year + month + day + date_trunc equal)', async (connection) => {
2220+
// It's important to use day granularity - it tests for ambiguous names
2221+
const res = await connection.query(`
2222+
SELECT
2223+
DATE_TRUNC('year', orderDate) AS "orderDateY",
2224+
DATE_TRUNC('month', orderDate) AS "orderDateM",
2225+
DATE_TRUNC('day', orderDate) AS "orderDateD",
2226+
MEASURE(rollingCountYTD) AS "rollingCountYTD"
2227+
FROM "BigECommerce"
2228+
WHERE DATE_TRUNC('year', orderDate) = CAST('2020-01-01' AS DATE)
2229+
GROUP BY 1, 2, 3
2230+
ORDER BY 3 ASC NULLS FIRST;
2231+
`);
2232+
expect(res.rows).toMatchSnapshot();
2233+
});
2234+
2235+
executePg('SQL API: Rolling Window YTD (year + month + day + date_trunc IN)', async (connection) => {
2236+
// It's important to use day granularity - it tests for ambiguous names
2237+
const res = await connection.query(`
2238+
SELECT
2239+
DATE_TRUNC('year', orderDate) AS "orderDateY",
2240+
DATE_TRUNC('month', orderDate) AS "orderDateM",
2241+
DATE_TRUNC('day', orderDate) AS "orderDateD",
2242+
MEASURE(rollingCountYTD) AS "rollingCountYTD"
2243+
FROM "BigECommerce"
2244+
WHERE DATE_TRUNC('year', orderDate) IN (CAST('2020-01-01' AS DATE))
2245+
GROUP BY 1, 2, 3
2246+
ORDER BY 3 ASC NULLS FIRST;
2247+
`);
2248+
expect(res.rows).toMatchSnapshot();
2249+
});
2250+
21052251
executePg('SQL API: SQL push down push to cube quoted alias', async (connection) => {
21062252
const res = await connection.query(`
21072253
SELECT

0 commit comments

Comments
 (0)