Skip to content

Commit

Permalink
add e2e tests for custom granularities with preaggregations
Browse files Browse the repository at this point in the history
  • Loading branch information
KSDaemon committed Sep 13, 2024
1 parent c7cf12c commit f8c2d25
Show file tree
Hide file tree
Showing 2 changed files with 55 additions and 1 deletion.
23 changes: 22 additions & 1 deletion packages/cubejs-testing-drivers/fixtures/_schemas.json
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,28 @@
{
"name": "orderDate",
"sql": "order_date",
"type": "time"
"type": "time",
"granularities": [
{
"name": "half_year",
"interval": "6 months"
},
{
"name": "half_year_by_1st_april",
"interval": "6 months",
"offset": "3 months"
},
{
"name": "two_mo_by_feb",
"interval": "2 months",
"origin": "2020-02-01 00:00:00"
},
{
"name": "three_months_by_march",
"interval": "3 month 3 days 3 hours",
"origin": "2020-03-15"
}
]
},
{
"name": "customOrderDateNoPreAgg",
Expand Down
33 changes: 33 additions & 0 deletions packages/cubejs-testing-drivers/src/tests/testQueries.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1750,6 +1750,39 @@ export function testQueries(type: string, { includeIncrementalSchemaSuite, exten
expect(response.rawData()).toMatchSnapshot();
});

execute('querying custom granularities (with preaggregation) ECommerce: totalQuantity by half_year + no dimension', async () => {
const response = await client.load({
measures: [
'ECommerce.totalQuantity',
],
timeDimensions: [{
dimension: 'ECommerce.orderDate',
granularity: 'half_year',
dateRange: ['2020-01-01', '2020-12-31'],
}],
});
expect(response.rawData()).toMatchSnapshot();
});

execute('querying custom granularities (with preaggregation) ECommerce: totalQuantity by half_year + dimension', async () => {
const response = await client.load({
measures: [
'ECommerce.totalQuantity',
],
timeDimensions: [{
dimension: 'ECommerce.orderDate',
granularity: 'half_year',
dateRange: ['2020-01-01', '2020-12-31'],
}],
dimensions: ['ECommerce.productName'],
order: [
['ECommerce.orderDate', 'asc'],
['ECommerce.productName', 'asc']
],
});
expect(response.rawData()).toMatchSnapshot();
});

if (includeIncrementalSchemaSuite) {
incrementalSchemaLoadingSuite(execute, () => driver, tables);
}
Expand Down

0 comments on commit f8c2d25

Please sign in to comment.