diff --git a/docs/pages/reference/data-model/dimensions.mdx b/docs/pages/reference/data-model/dimensions.mdx index cdeee806f31b4..a9291ffd6b478 100644 --- a/docs/pages/reference/data-model/dimensions.mdx +++ b/docs/pages/reference/data-model/dimensions.mdx @@ -618,6 +618,14 @@ examples. + + +Custom granularities are supported for the following [data sources][ref-data-sources]: +Amazon Athena, Amazon Redshift, DuckDB, Databricks, Google BigQuery, ClickHouse, Microsoft SQL Server, MySQL, Postgres, and Snowflake. +Please [file an issue](https://github.com/cube-js/cube/issues) if you need support for another data source. + + + For each custom granularity, the `interval` parameter is required. It specifies the duration of the time interval and has the following format: `quantity unit [quantity unit...]`, e.g., `5 days` or `1 year 6 months`. @@ -713,4 +721,5 @@ cube(`orders`, { [ref-time-dimensions]: /reference/data-model/types-and-formats#time-1 [link-date-time-string]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date#date_time_string_format [ref-custom-granularity-recipe]: /guides/recipes/data-modeling/custom-granularity -[ref-ref-hierarchies]: /reference/data-model/hierarchies \ No newline at end of file +[ref-ref-hierarchies]: /reference/data-model/hierarchies +[ref-data-sources]: /product/configuration/data-sources \ No newline at end of file diff --git a/packages/cubejs-schema-compiler/src/adapter/BaseQuery.js b/packages/cubejs-schema-compiler/src/adapter/BaseQuery.js index 234ca924bb6f4..81080159ade18 100644 --- a/packages/cubejs-schema-compiler/src/adapter/BaseQuery.js +++ b/packages/cubejs-schema-compiler/src/adapter/BaseQuery.js @@ -3110,7 +3110,7 @@ export class BaseQuery { */ // eslint-disable-next-line @typescript-eslint/no-unused-vars dateBin(interval, source, origin) { - throw new Error('Date bin function is not implemented'); + throw new Error('Date bin function, required for custom time dimension granularities, is not implemented for this data source'); // Different syntax possible in different DBs } diff --git a/packages/cubejs-schema-compiler/src/adapter/PreAggregations.js b/packages/cubejs-schema-compiler/src/adapter/PreAggregations.js index 66d90a4b430be..f5b73d7c2b65a 100644 --- a/packages/cubejs-schema-compiler/src/adapter/PreAggregations.js +++ b/packages/cubejs-schema-compiler/src/adapter/PreAggregations.js @@ -156,7 +156,7 @@ export class PreAggregations { const tableName = this.preAggregationTableName(cube, preAggregationName, preAggregation); const invalidateKeyQueries = this.query.preAggregationInvalidateKeyQueries(cube, preAggregation, preAggregationName); const queryForSqlEvaluation = this.query.preAggregationQueryForSqlEvaluation(cube, preAggregation); - const partitionInvalidateKeyQueries = queryForSqlEvaluation.partitionInvalidateKeyQueries && queryForSqlEvaluation.partitionInvalidateKeyQueries(cube, preAggregation); + const partitionInvalidateKeyQueries = queryForSqlEvaluation.partitionInvalidateKeyQueries?.(cube, preAggregation); const allBackAliasMembers = this.query.allBackAliasMembers(); diff --git a/packages/cubejs-schema-compiler/src/adapter/PrestodbQuery.ts b/packages/cubejs-schema-compiler/src/adapter/PrestodbQuery.ts index 2fd6c4ed9f556..832b47e9cfc63 100644 --- a/packages/cubejs-schema-compiler/src/adapter/PrestodbQuery.ts +++ b/packages/cubejs-schema-compiler/src/adapter/PrestodbQuery.ts @@ -1,3 +1,4 @@ +import { parseSqlInterval } from '@cubejs-backend/shared'; import { BaseQuery } from './BaseQuery'; import { BaseFilter } from './BaseFilter'; @@ -55,6 +56,30 @@ export class PrestodbQuery extends BaseQuery { field; } + /** + * Returns sql for source expression floored to timestamps aligned with + * intervals relative to origin timestamp point. + * Athena doesn't support INTERVALs directly — using date_diff/date_add + */ + public dateBin(interval: string, source: string, origin: string): string { + const intervalParsed = parseSqlInterval(interval); + const intervalParts = Object.entries(intervalParsed); + + if (intervalParts.length > 1) { + throw new Error('Athena/Presto supports only simple intervals with one date part'); + } + + const [unit, count] = intervalParts[0]; + const originExpr = this.timeStampCast(`'${origin}'`); + + return `date_add('${unit}', + floor( + date_diff('${unit}', ${originExpr}, ${source}) / ${count} + ) * ${count}, + ${originExpr} + )`; + } + public timeGroupedColumn(granularity, dimension) { return `date_trunc('${GRANULARITY_TO_INTERVAL[granularity]}', ${dimension})`; } diff --git a/packages/cubejs-server-core/src/core/DriverResolvers.ts b/packages/cubejs-server-core/src/core/DriverResolvers.ts index 46df0f1f85939..5fa4d1379adff 100644 --- a/packages/cubejs-server-core/src/core/DriverResolvers.ts +++ b/packages/cubejs-server-core/src/core/DriverResolvers.ts @@ -49,13 +49,13 @@ export const lookupDriverClass = (dbType): Constructor & { */ export const isDriver = (val: any): boolean => { let isDriverInstance = val instanceof BaseDriver; - if (!isDriverInstance && val && val.constructor) { + if (!isDriverInstance && val?.constructor) { let end = false; let obj = val.constructor; while (!isDriverInstance && !end) { obj = Object.getPrototypeOf(obj); end = !obj; - isDriverInstance = obj && obj.name ? obj.name === 'BaseDriver' : false; + isDriverInstance = obj?.name ? obj.name === 'BaseDriver' : false; } } return isDriverInstance; @@ -82,11 +82,11 @@ export const getDriverMaxPool = async ( const queryQueueOptions = await options .queryCacheOptions .queueOptions(context.dataSource); - + const preAggregationsQueueOptions = await options .preAggregationsOptions .queueOptions(context.dataSource); - + return 2 * ( queryQueueOptions.concurrency + preAggregationsQueueOptions.concurrency diff --git a/packages/cubejs-testing-drivers/fixtures/athena.json b/packages/cubejs-testing-drivers/fixtures/athena.json index 301ba6c1dd39a..2041681230409 100644 --- a/packages/cubejs-testing-drivers/fixtures/athena.json +++ b/packages/cubejs-testing-drivers/fixtures/athena.json @@ -151,15 +151,8 @@ "---------------------------------------", "Custom Granularities ", "---------------------------------------", - "querying custom granularities ECommerce: count by half_year + no dimension", - "querying custom granularities ECommerce: count by half_year_by_1st_april + no dimension", "querying custom granularities ECommerce: count by three_months_by_march + no dimension", - "querying custom granularities ECommerce: count by half_year + dimension", - "querying custom granularities ECommerce: count by half_year_by_1st_april + dimension", "querying custom granularities ECommerce: count by three_months_by_march + dimension", - "querying custom granularities ECommerce: count by two_mo_by_feb + no dimension + rollingCountByUnbounded", - "querying custom granularities ECommerce: count by two_mo_by_feb + no dimension + rollingCountByTrailing", - "querying custom granularities ECommerce: count by two_mo_by_feb + no dimension + rollingCountByLeading", "SKIPPED SQL API (Need work)", "---------------------------------------", diff --git a/packages/cubejs-testing-drivers/test/__snapshots__/athena-export-bucket-s3-full.test.ts.snap b/packages/cubejs-testing-drivers/test/__snapshots__/athena-export-bucket-s3-full.test.ts.snap index 5221fdaa4839e..748c08d81a9af 100644 --- a/packages/cubejs-testing-drivers/test/__snapshots__/athena-export-bucket-s3-full.test.ts.snap +++ b/packages/cubejs-testing-drivers/test/__snapshots__/athena-export-bucket-s3-full.test.ts.snap @@ -7418,3 +7418,539 @@ Array [ }, ] `; + +exports[`Queries with the @cubejs-backend/athena-driver querying custom granularities ECommerce: count by half_year + dimension 1`] = ` +Array [ + Object { + "ECommerce.city": "Lorain", + "ECommerce.count": "1", + "ECommerce.customOrderDateNoPreAgg": "2020-01-01T00:00:00.000", + "ECommerce.customOrderDateNoPreAgg.half_year": "2020-01-01T00:00:00.000", + }, + Object { + "ECommerce.city": "Auburn", + "ECommerce.count": "1", + "ECommerce.customOrderDateNoPreAgg": "2020-07-01T00:00:00.000", + "ECommerce.customOrderDateNoPreAgg.half_year": "2020-07-01T00:00:00.000", + }, + Object { + "ECommerce.city": "Baltimore", + "ECommerce.count": "1", + "ECommerce.customOrderDateNoPreAgg": "2020-07-01T00:00:00.000", + "ECommerce.customOrderDateNoPreAgg.half_year": "2020-07-01T00:00:00.000", + }, + Object { + "ECommerce.city": "Columbus", + "ECommerce.count": "3", + "ECommerce.customOrderDateNoPreAgg": "2020-07-01T00:00:00.000", + "ECommerce.customOrderDateNoPreAgg.half_year": "2020-07-01T00:00:00.000", + }, + Object { + "ECommerce.city": "Decatur", + "ECommerce.count": "1", + "ECommerce.customOrderDateNoPreAgg": "2020-07-01T00:00:00.000", + "ECommerce.customOrderDateNoPreAgg.half_year": "2020-07-01T00:00:00.000", + }, + Object { + "ECommerce.city": "Detroit", + "ECommerce.count": "1", + "ECommerce.customOrderDateNoPreAgg": "2020-07-01T00:00:00.000", + "ECommerce.customOrderDateNoPreAgg.half_year": "2020-07-01T00:00:00.000", + }, + Object { + "ECommerce.city": "Houston", + "ECommerce.count": "1", + "ECommerce.customOrderDateNoPreAgg": "2020-07-01T00:00:00.000", + "ECommerce.customOrderDateNoPreAgg.half_year": "2020-07-01T00:00:00.000", + }, + Object { + "ECommerce.city": "Los Angeles", + "ECommerce.count": "1", + "ECommerce.customOrderDateNoPreAgg": "2020-07-01T00:00:00.000", + "ECommerce.customOrderDateNoPreAgg.half_year": "2020-07-01T00:00:00.000", + }, + Object { + "ECommerce.city": "Louisville", + "ECommerce.count": "1", + "ECommerce.customOrderDateNoPreAgg": "2020-07-01T00:00:00.000", + "ECommerce.customOrderDateNoPreAgg.half_year": "2020-07-01T00:00:00.000", + }, + Object { + "ECommerce.city": "New York City", + "ECommerce.count": "4", + "ECommerce.customOrderDateNoPreAgg": "2020-07-01T00:00:00.000", + "ECommerce.customOrderDateNoPreAgg.half_year": "2020-07-01T00:00:00.000", + }, + Object { + "ECommerce.city": "Olympia", + "ECommerce.count": "1", + "ECommerce.customOrderDateNoPreAgg": "2020-07-01T00:00:00.000", + "ECommerce.customOrderDateNoPreAgg.half_year": "2020-07-01T00:00:00.000", + }, + Object { + "ECommerce.city": "Omaha", + "ECommerce.count": "1", + "ECommerce.customOrderDateNoPreAgg": "2020-07-01T00:00:00.000", + "ECommerce.customOrderDateNoPreAgg.half_year": "2020-07-01T00:00:00.000", + }, + Object { + "ECommerce.city": "Philadelphia", + "ECommerce.count": "1", + "ECommerce.customOrderDateNoPreAgg": "2020-07-01T00:00:00.000", + "ECommerce.customOrderDateNoPreAgg.half_year": "2020-07-01T00:00:00.000", + }, + Object { + "ECommerce.city": "Arlington", + "ECommerce.count": "1", + "ECommerce.customOrderDateNoPreAgg": "2021-01-01T00:00:00.000", + "ECommerce.customOrderDateNoPreAgg.half_year": "2021-01-01T00:00:00.000", + }, + Object { + "ECommerce.city": "Bakersfield", + "ECommerce.count": "1", + "ECommerce.customOrderDateNoPreAgg": "2021-01-01T00:00:00.000", + "ECommerce.customOrderDateNoPreAgg.half_year": "2021-01-01T00:00:00.000", + }, + Object { + "ECommerce.city": "Bowling", + "ECommerce.count": "1", + "ECommerce.customOrderDateNoPreAgg": "2021-01-01T00:00:00.000", + "ECommerce.customOrderDateNoPreAgg.half_year": "2021-01-01T00:00:00.000", + }, + Object { + "ECommerce.city": "Columbus", + "ECommerce.count": "9", + "ECommerce.customOrderDateNoPreAgg": "2021-01-01T00:00:00.000", + "ECommerce.customOrderDateNoPreAgg.half_year": "2021-01-01T00:00:00.000", + }, + Object { + "ECommerce.city": "Dallas", + "ECommerce.count": "1", + "ECommerce.customOrderDateNoPreAgg": "2021-01-01T00:00:00.000", + "ECommerce.customOrderDateNoPreAgg.half_year": "2021-01-01T00:00:00.000", + }, + Object { + "ECommerce.city": "Detroit", + "ECommerce.count": "1", + "ECommerce.customOrderDateNoPreAgg": "2021-01-01T00:00:00.000", + "ECommerce.customOrderDateNoPreAgg.half_year": "2021-01-01T00:00:00.000", + }, + Object { + "ECommerce.city": "Glendale", + "ECommerce.count": "1", + "ECommerce.customOrderDateNoPreAgg": "2021-01-01T00:00:00.000", + "ECommerce.customOrderDateNoPreAgg.half_year": "2021-01-01T00:00:00.000", + }, + Object { + "ECommerce.city": "Lafayette", + "ECommerce.count": "1", + "ECommerce.customOrderDateNoPreAgg": "2021-01-01T00:00:00.000", + "ECommerce.customOrderDateNoPreAgg.half_year": "2021-01-01T00:00:00.000", + }, + Object { + "ECommerce.city": "Lakewood", + "ECommerce.count": "1", + "ECommerce.customOrderDateNoPreAgg": "2021-01-01T00:00:00.000", + "ECommerce.customOrderDateNoPreAgg.half_year": "2021-01-01T00:00:00.000", + }, + Object { + "ECommerce.city": "Marion", + "ECommerce.count": "1", + "ECommerce.customOrderDateNoPreAgg": "2021-01-01T00:00:00.000", + "ECommerce.customOrderDateNoPreAgg.half_year": "2021-01-01T00:00:00.000", + }, + Object { + "ECommerce.city": "Morristown", + "ECommerce.count": "1", + "ECommerce.customOrderDateNoPreAgg": "2021-01-01T00:00:00.000", + "ECommerce.customOrderDateNoPreAgg.half_year": "2021-01-01T00:00:00.000", + }, + Object { + "ECommerce.city": "New York City", + "ECommerce.count": "1", + "ECommerce.customOrderDateNoPreAgg": "2021-01-01T00:00:00.000", + "ECommerce.customOrderDateNoPreAgg.half_year": "2021-01-01T00:00:00.000", + }, + Object { + "ECommerce.city": "Oakland", + "ECommerce.count": "1", + "ECommerce.customOrderDateNoPreAgg": "2021-01-01T00:00:00.000", + "ECommerce.customOrderDateNoPreAgg.half_year": "2021-01-01T00:00:00.000", + }, + Object { + "ECommerce.city": "Philadelphia", + "ECommerce.count": "1", + "ECommerce.customOrderDateNoPreAgg": "2021-01-01T00:00:00.000", + "ECommerce.customOrderDateNoPreAgg.half_year": "2021-01-01T00:00:00.000", + }, + Object { + "ECommerce.city": "Provo", + "ECommerce.count": "1", + "ECommerce.customOrderDateNoPreAgg": "2021-01-01T00:00:00.000", + "ECommerce.customOrderDateNoPreAgg.half_year": "2021-01-01T00:00:00.000", + }, + Object { + "ECommerce.city": "San Francisco", + "ECommerce.count": "2", + "ECommerce.customOrderDateNoPreAgg": "2021-01-01T00:00:00.000", + "ECommerce.customOrderDateNoPreAgg.half_year": "2021-01-01T00:00:00.000", + }, + Object { + "ECommerce.city": "Vancouver", + "ECommerce.count": "1", + "ECommerce.customOrderDateNoPreAgg": "2021-01-01T00:00:00.000", + "ECommerce.customOrderDateNoPreAgg.half_year": "2021-01-01T00:00:00.000", + }, +] +`; + +exports[`Queries with the @cubejs-backend/athena-driver querying custom granularities ECommerce: count by half_year + no dimension 1`] = ` +Array [ + Object { + "ECommerce.count": "1", + "ECommerce.customOrderDateNoPreAgg": "2020-01-01T00:00:00.000", + "ECommerce.customOrderDateNoPreAgg.half_year": "2020-01-01T00:00:00.000", + }, + Object { + "ECommerce.count": "17", + "ECommerce.customOrderDateNoPreAgg": "2020-07-01T00:00:00.000", + "ECommerce.customOrderDateNoPreAgg.half_year": "2020-07-01T00:00:00.000", + }, + Object { + "ECommerce.count": "26", + "ECommerce.customOrderDateNoPreAgg": "2021-01-01T00:00:00.000", + "ECommerce.customOrderDateNoPreAgg.half_year": "2021-01-01T00:00:00.000", + }, +] +`; + +exports[`Queries with the @cubejs-backend/athena-driver querying custom granularities ECommerce: count by half_year_by_1st_april + dimension 1`] = ` +Array [ + Object { + "ECommerce.city": "Decatur", + "ECommerce.count": "1", + "ECommerce.customOrderDateNoPreAgg": "2020-04-01T00:00:00.000", + "ECommerce.customOrderDateNoPreAgg.half_year_by_1st_april": "2020-04-01T00:00:00.000", + }, + Object { + "ECommerce.city": "Detroit", + "ECommerce.count": "1", + "ECommerce.customOrderDateNoPreAgg": "2020-04-01T00:00:00.000", + "ECommerce.customOrderDateNoPreAgg.half_year_by_1st_april": "2020-04-01T00:00:00.000", + }, + Object { + "ECommerce.city": "Houston", + "ECommerce.count": "1", + "ECommerce.customOrderDateNoPreAgg": "2020-04-01T00:00:00.000", + "ECommerce.customOrderDateNoPreAgg.half_year_by_1st_april": "2020-04-01T00:00:00.000", + }, + Object { + "ECommerce.city": "Lorain", + "ECommerce.count": "1", + "ECommerce.customOrderDateNoPreAgg": "2020-04-01T00:00:00.000", + "ECommerce.customOrderDateNoPreAgg.half_year_by_1st_april": "2020-04-01T00:00:00.000", + }, + Object { + "ECommerce.city": "New York City", + "ECommerce.count": "1", + "ECommerce.customOrderDateNoPreAgg": "2020-04-01T00:00:00.000", + "ECommerce.customOrderDateNoPreAgg.half_year_by_1st_april": "2020-04-01T00:00:00.000", + }, + Object { + "ECommerce.city": "Arlington", + "ECommerce.count": "1", + "ECommerce.customOrderDateNoPreAgg": "2020-10-01T00:00:00.000", + "ECommerce.customOrderDateNoPreAgg.half_year_by_1st_april": "2020-10-01T00:00:00.000", + }, + Object { + "ECommerce.city": "Auburn", + "ECommerce.count": "1", + "ECommerce.customOrderDateNoPreAgg": "2020-10-01T00:00:00.000", + "ECommerce.customOrderDateNoPreAgg.half_year_by_1st_april": "2020-10-01T00:00:00.000", + }, + Object { + "ECommerce.city": "Bakersfield", + "ECommerce.count": "1", + "ECommerce.customOrderDateNoPreAgg": "2020-10-01T00:00:00.000", + "ECommerce.customOrderDateNoPreAgg.half_year_by_1st_april": "2020-10-01T00:00:00.000", + }, + Object { + "ECommerce.city": "Baltimore", + "ECommerce.count": "1", + "ECommerce.customOrderDateNoPreAgg": "2020-10-01T00:00:00.000", + "ECommerce.customOrderDateNoPreAgg.half_year_by_1st_april": "2020-10-01T00:00:00.000", + }, + Object { + "ECommerce.city": "Columbus", + "ECommerce.count": "4", + "ECommerce.customOrderDateNoPreAgg": "2020-10-01T00:00:00.000", + "ECommerce.customOrderDateNoPreAgg.half_year_by_1st_april": "2020-10-01T00:00:00.000", + }, + Object { + "ECommerce.city": "Detroit", + "ECommerce.count": "1", + "ECommerce.customOrderDateNoPreAgg": "2020-10-01T00:00:00.000", + "ECommerce.customOrderDateNoPreAgg.half_year_by_1st_april": "2020-10-01T00:00:00.000", + }, + Object { + "ECommerce.city": "Los Angeles", + "ECommerce.count": "1", + "ECommerce.customOrderDateNoPreAgg": "2020-10-01T00:00:00.000", + "ECommerce.customOrderDateNoPreAgg.half_year_by_1st_april": "2020-10-01T00:00:00.000", + }, + Object { + "ECommerce.city": "Louisville", + "ECommerce.count": "1", + "ECommerce.customOrderDateNoPreAgg": "2020-10-01T00:00:00.000", + "ECommerce.customOrderDateNoPreAgg.half_year_by_1st_april": "2020-10-01T00:00:00.000", + }, + Object { + "ECommerce.city": "Morristown", + "ECommerce.count": "1", + "ECommerce.customOrderDateNoPreAgg": "2020-10-01T00:00:00.000", + "ECommerce.customOrderDateNoPreAgg.half_year_by_1st_april": "2020-10-01T00:00:00.000", + }, + Object { + "ECommerce.city": "New York City", + "ECommerce.count": "3", + "ECommerce.customOrderDateNoPreAgg": "2020-10-01T00:00:00.000", + "ECommerce.customOrderDateNoPreAgg.half_year_by_1st_april": "2020-10-01T00:00:00.000", + }, + Object { + "ECommerce.city": "Olympia", + "ECommerce.count": "1", + "ECommerce.customOrderDateNoPreAgg": "2020-10-01T00:00:00.000", + "ECommerce.customOrderDateNoPreAgg.half_year_by_1st_april": "2020-10-01T00:00:00.000", + }, + Object { + "ECommerce.city": "Omaha", + "ECommerce.count": "1", + "ECommerce.customOrderDateNoPreAgg": "2020-10-01T00:00:00.000", + "ECommerce.customOrderDateNoPreAgg.half_year_by_1st_april": "2020-10-01T00:00:00.000", + }, + Object { + "ECommerce.city": "Philadelphia", + "ECommerce.count": "1", + "ECommerce.customOrderDateNoPreAgg": "2020-10-01T00:00:00.000", + "ECommerce.customOrderDateNoPreAgg.half_year_by_1st_april": "2020-10-01T00:00:00.000", + }, + Object { + "ECommerce.city": "Provo", + "ECommerce.count": "1", + "ECommerce.customOrderDateNoPreAgg": "2020-10-01T00:00:00.000", + "ECommerce.customOrderDateNoPreAgg.half_year_by_1st_april": "2020-10-01T00:00:00.000", + }, + Object { + "ECommerce.city": "Bowling", + "ECommerce.count": "1", + "ECommerce.customOrderDateNoPreAgg": "2021-04-01T00:00:00.000", + "ECommerce.customOrderDateNoPreAgg.half_year_by_1st_april": "2021-04-01T00:00:00.000", + }, + Object { + "ECommerce.city": "Columbus", + "ECommerce.count": "8", + "ECommerce.customOrderDateNoPreAgg": "2021-04-01T00:00:00.000", + "ECommerce.customOrderDateNoPreAgg.half_year_by_1st_april": "2021-04-01T00:00:00.000", + }, + Object { + "ECommerce.city": "Dallas", + "ECommerce.count": "1", + "ECommerce.customOrderDateNoPreAgg": "2021-04-01T00:00:00.000", + "ECommerce.customOrderDateNoPreAgg.half_year_by_1st_april": "2021-04-01T00:00:00.000", + }, + Object { + "ECommerce.city": "Glendale", + "ECommerce.count": "1", + "ECommerce.customOrderDateNoPreAgg": "2021-04-01T00:00:00.000", + "ECommerce.customOrderDateNoPreAgg.half_year_by_1st_april": "2021-04-01T00:00:00.000", + }, + Object { + "ECommerce.city": "Lafayette", + "ECommerce.count": "1", + "ECommerce.customOrderDateNoPreAgg": "2021-04-01T00:00:00.000", + "ECommerce.customOrderDateNoPreAgg.half_year_by_1st_april": "2021-04-01T00:00:00.000", + }, + Object { + "ECommerce.city": "Lakewood", + "ECommerce.count": "1", + "ECommerce.customOrderDateNoPreAgg": "2021-04-01T00:00:00.000", + "ECommerce.customOrderDateNoPreAgg.half_year_by_1st_april": "2021-04-01T00:00:00.000", + }, + Object { + "ECommerce.city": "Marion", + "ECommerce.count": "1", + "ECommerce.customOrderDateNoPreAgg": "2021-04-01T00:00:00.000", + "ECommerce.customOrderDateNoPreAgg.half_year_by_1st_april": "2021-04-01T00:00:00.000", + }, + Object { + "ECommerce.city": "New York City", + "ECommerce.count": "1", + "ECommerce.customOrderDateNoPreAgg": "2021-04-01T00:00:00.000", + "ECommerce.customOrderDateNoPreAgg.half_year_by_1st_april": "2021-04-01T00:00:00.000", + }, + Object { + "ECommerce.city": "Oakland", + "ECommerce.count": "1", + "ECommerce.customOrderDateNoPreAgg": "2021-04-01T00:00:00.000", + "ECommerce.customOrderDateNoPreAgg.half_year_by_1st_april": "2021-04-01T00:00:00.000", + }, + Object { + "ECommerce.city": "Philadelphia", + "ECommerce.count": "1", + "ECommerce.customOrderDateNoPreAgg": "2021-04-01T00:00:00.000", + "ECommerce.customOrderDateNoPreAgg.half_year_by_1st_april": "2021-04-01T00:00:00.000", + }, + Object { + "ECommerce.city": "San Francisco", + "ECommerce.count": "2", + "ECommerce.customOrderDateNoPreAgg": "2021-04-01T00:00:00.000", + "ECommerce.customOrderDateNoPreAgg.half_year_by_1st_april": "2021-04-01T00:00:00.000", + }, + Object { + "ECommerce.city": "Vancouver", + "ECommerce.count": "1", + "ECommerce.customOrderDateNoPreAgg": "2021-04-01T00:00:00.000", + "ECommerce.customOrderDateNoPreAgg.half_year_by_1st_april": "2021-04-01T00:00:00.000", + }, +] +`; + +exports[`Queries with the @cubejs-backend/athena-driver querying custom granularities ECommerce: count by half_year_by_1st_april + no dimension 1`] = ` +Array [ + Object { + "ECommerce.count": "5", + "ECommerce.customOrderDateNoPreAgg": "2020-04-01T00:00:00.000", + "ECommerce.customOrderDateNoPreAgg.half_year_by_1st_april": "2020-04-01T00:00:00.000", + }, + Object { + "ECommerce.count": "19", + "ECommerce.customOrderDateNoPreAgg": "2020-10-01T00:00:00.000", + "ECommerce.customOrderDateNoPreAgg.half_year_by_1st_april": "2020-10-01T00:00:00.000", + }, + Object { + "ECommerce.count": "20", + "ECommerce.customOrderDateNoPreAgg": "2021-04-01T00:00:00.000", + "ECommerce.customOrderDateNoPreAgg.half_year_by_1st_april": "2021-04-01T00:00:00.000", + }, +] +`; + +exports[`Queries with the @cubejs-backend/athena-driver querying custom granularities ECommerce: count by two_mo_by_feb + no dimension + rollingCountByLeading 1`] = ` +Array [ + Object { + "ECommerce.customOrderDateNoPreAgg": "2019-12-01T10:00:00.000", + "ECommerce.customOrderDateNoPreAgg.two_mo_by_feb": "2019-12-01T10:00:00.000", + "ECommerce.rollingCountByLeading": "8", + }, + Object { + "ECommerce.customOrderDateNoPreAgg": "2020-02-01T10:00:00.000", + "ECommerce.customOrderDateNoPreAgg.two_mo_by_feb": "2020-02-01T10:00:00.000", + "ECommerce.rollingCountByLeading": "12", + }, + Object { + "ECommerce.customOrderDateNoPreAgg": "2020-04-01T10:00:00.000", + "ECommerce.customOrderDateNoPreAgg.two_mo_by_feb": "2020-04-01T10:00:00.000", + "ECommerce.rollingCountByLeading": "6", + }, + Object { + "ECommerce.customOrderDateNoPreAgg": "2020-06-01T10:00:00.000", + "ECommerce.customOrderDateNoPreAgg.two_mo_by_feb": "2020-06-01T10:00:00.000", + "ECommerce.rollingCountByLeading": "19", + }, + Object { + "ECommerce.customOrderDateNoPreAgg": "2020-08-01T10:00:00.000", + "ECommerce.customOrderDateNoPreAgg.two_mo_by_feb": "2020-08-01T10:00:00.000", + "ECommerce.rollingCountByLeading": "16", + }, + Object { + "ECommerce.customOrderDateNoPreAgg": "2020-10-01T10:00:00.000", + "ECommerce.customOrderDateNoPreAgg.two_mo_by_feb": "2020-10-01T10:00:00.000", + "ECommerce.rollingCountByLeading": null, + }, + Object { + "ECommerce.customOrderDateNoPreAgg": "2020-12-01T10:00:00.000", + "ECommerce.customOrderDateNoPreAgg.two_mo_by_feb": "2020-12-01T10:00:00.000", + "ECommerce.rollingCountByLeading": null, + }, +] +`; + +exports[`Queries with the @cubejs-backend/athena-driver querying custom granularities ECommerce: count by two_mo_by_feb + no dimension + rollingCountByTrailing 1`] = ` +Array [ + Object { + "ECommerce.customOrderDateNoPreAgg": "2019-12-01T10:00:00.000", + "ECommerce.customOrderDateNoPreAgg.two_mo_by_feb": "2019-12-01T10:00:00.000", + "ECommerce.rollingCountByTrailing": "3", + }, + Object { + "ECommerce.customOrderDateNoPreAgg": "2020-02-01T10:00:00.000", + "ECommerce.customOrderDateNoPreAgg.two_mo_by_feb": "2020-02-01T10:00:00.000", + "ECommerce.rollingCountByTrailing": "3", + }, + Object { + "ECommerce.customOrderDateNoPreAgg": "2020-04-01T10:00:00.000", + "ECommerce.customOrderDateNoPreAgg.two_mo_by_feb": "2020-04-01T10:00:00.000", + "ECommerce.rollingCountByTrailing": "12", + }, + Object { + "ECommerce.customOrderDateNoPreAgg": "2020-06-01T10:00:00.000", + "ECommerce.customOrderDateNoPreAgg.two_mo_by_feb": "2020-06-01T10:00:00.000", + "ECommerce.rollingCountByTrailing": null, + }, + Object { + "ECommerce.customOrderDateNoPreAgg": "2020-08-01T10:00:00.000", + "ECommerce.customOrderDateNoPreAgg.two_mo_by_feb": "2020-08-01T10:00:00.000", + "ECommerce.rollingCountByTrailing": "10", + }, + Object { + "ECommerce.customOrderDateNoPreAgg": "2020-10-01T10:00:00.000", + "ECommerce.customOrderDateNoPreAgg.two_mo_by_feb": "2020-10-01T10:00:00.000", + "ECommerce.rollingCountByTrailing": "16", + }, + Object { + "ECommerce.customOrderDateNoPreAgg": "2020-12-01T10:00:00.000", + "ECommerce.customOrderDateNoPreAgg.two_mo_by_feb": "2020-12-01T10:00:00.000", + "ECommerce.rollingCountByTrailing": null, + }, +] +`; + +exports[`Queries with the @cubejs-backend/athena-driver querying custom granularities ECommerce: count by two_mo_by_feb + no dimension + rollingCountByUnbounded 1`] = ` +Array [ + Object { + "ECommerce.customOrderDateNoPreAgg": "2019-12-01T10:00:00.000", + "ECommerce.customOrderDateNoPreAgg.two_mo_by_feb": "2019-12-01T10:00:00.000", + "ECommerce.rollingCountByUnbounded": "3", + }, + Object { + "ECommerce.customOrderDateNoPreAgg": "2020-02-01T10:00:00.000", + "ECommerce.customOrderDateNoPreAgg.two_mo_by_feb": "2020-02-01T10:00:00.000", + "ECommerce.rollingCountByUnbounded": "6", + }, + Object { + "ECommerce.customOrderDateNoPreAgg": "2020-04-01T10:00:00.000", + "ECommerce.customOrderDateNoPreAgg.two_mo_by_feb": "2020-04-01T10:00:00.000", + "ECommerce.rollingCountByUnbounded": "18", + }, + Object { + "ECommerce.customOrderDateNoPreAgg": "2020-06-01T10:00:00.000", + "ECommerce.customOrderDateNoPreAgg.two_mo_by_feb": "2020-06-01T10:00:00.000", + "ECommerce.rollingCountByUnbounded": "18", + }, + Object { + "ECommerce.customOrderDateNoPreAgg": "2020-08-01T10:00:00.000", + "ECommerce.customOrderDateNoPreAgg.two_mo_by_feb": "2020-08-01T10:00:00.000", + "ECommerce.rollingCountByUnbounded": "28", + }, + Object { + "ECommerce.customOrderDateNoPreAgg": "2020-10-01T10:00:00.000", + "ECommerce.customOrderDateNoPreAgg.two_mo_by_feb": "2020-10-01T10:00:00.000", + "ECommerce.rollingCountByUnbounded": "44", + }, + Object { + "ECommerce.customOrderDateNoPreAgg": "2020-12-01T10:00:00.000", + "ECommerce.customOrderDateNoPreAgg.two_mo_by_feb": "2020-12-01T10:00:00.000", + "ECommerce.rollingCountByUnbounded": "44", + }, +] +`;