diff --git a/packages/cubejs-testing-drivers/fixtures/_schemas.json b/packages/cubejs-testing-drivers/fixtures/_schemas.json index 74f31cc4ce9c9..5dab6f5668caf 100644 --- a/packages/cubejs-testing-drivers/fixtures/_schemas.json +++ b/packages/cubejs-testing-drivers/fixtures/_schemas.json @@ -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", diff --git a/packages/cubejs-testing-drivers/src/tests/testQueries.ts b/packages/cubejs-testing-drivers/src/tests/testQueries.ts index acec3d7afc698..c4a2f9f417d7c 100644 --- a/packages/cubejs-testing-drivers/src/tests/testQueries.ts +++ b/packages/cubejs-testing-drivers/src/tests/testQueries.ts @@ -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); }