diff --git a/packages/cubejs-backend-native/Cargo.lock b/packages/cubejs-backend-native/Cargo.lock index 2b6c21e12b496..4bbe0c2ca4ba5 100644 --- a/packages/cubejs-backend-native/Cargo.lock +++ b/packages/cubejs-backend-native/Cargo.lock @@ -826,6 +826,7 @@ dependencies = [ "serde", "serde_json", "tokio", + "typed-builder", ] [[package]] @@ -3619,6 +3620,26 @@ dependencies = [ "utf-8", ] +[[package]] +name = "typed-builder" +version = "0.21.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fef81aec2ca29576f9f6ae8755108640d0a86dd3161b2e8bca6cfa554e98f77d" +dependencies = [ + "typed-builder-macro", +] + +[[package]] +name = "typed-builder-macro" +version = "0.21.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1ecb9ecf7799210407c14a8cfdfe0173365780968dc57973ed082211958e0b18" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.98", +] + [[package]] name = "typenum" version = "1.17.0" diff --git a/packages/cubejs-schema-compiler/src/adapter/BaseQuery.js b/packages/cubejs-schema-compiler/src/adapter/BaseQuery.js index 5f9498340b4ae..52606270cc64f 100644 --- a/packages/cubejs-schema-compiler/src/adapter/BaseQuery.js +++ b/packages/cubejs-schema-compiler/src/adapter/BaseQuery.js @@ -3232,6 +3232,9 @@ export class BaseQuery { } if (symbol.case) { return this.renderDimensionCase(symbol, cubeName); + } else if (symbol.type === 'switch') { + // Dimension of type switch is not supported in BaseQuery, return an empty string to make dependency resolution work. + return ''; } else if (symbol.type === 'geo') { return this.concatStringsSql([ this.autoPrefixAndEvaluateSql(cubeName, symbol.latitude.sql, isMemberExpr), @@ -4210,7 +4213,17 @@ export class BaseQuery { time_series_get_range: 'SELECT {{ max_expr }} as {{ quoted_max_name }},\n' + '{{ min_expr }} as {{ quoted_min_name }}\n' + 'FROM {{ from_prepared }}\n' + - '{% if filter %}WHERE {{ filter }}{% endif %}' + '{% if filter %}WHERE {{ filter }}{% endif %}', + calc_groups_join: '{% if original_sql %}{{ original_sql }}\n{% endif %}' + + '{% for group in groups %}' + + '{% if original_sql or not loop.first %}CROSS JOIN\n{% endif %}' + + '(\n' + + '{% for value in group.values %}' + + 'SELECT {{ value }} as {{ group.name }}' + + '{% if not loop.last %} UNION ALL\n{% endif %}' + + '{% endfor %}' + + ') AS {{ group.alias }}\n' + + '{% endfor %}' }, expressions: { column_reference: '{% if table_name %}{{ table_name }}.{% endif %}{{ name }}', diff --git a/packages/cubejs-schema-compiler/src/compiler/CubeEvaluator.ts b/packages/cubejs-schema-compiler/src/compiler/CubeEvaluator.ts index 649bf02982784..e540183d3d9a8 100644 --- a/packages/cubejs-schema-compiler/src/compiler/CubeEvaluator.ts +++ b/packages/cubejs-schema-compiler/src/compiler/CubeEvaluator.ts @@ -547,6 +547,9 @@ export class CubeEvaluator extends CubeSymbols { let aliasMember; const member = members[memberName]; + if (member.type === 'switch' || member.multiStage) { + ownedByCube = false; + } if (member.sql && !member.subQuery) { const funcArgs = this.funcArguments(member.sql); const { cubeReferencesUsed, evaluatedSql, pathReferencesUsed } = this.collectUsedCubeReferences(cube.name, member.sql); diff --git a/packages/cubejs-schema-compiler/src/compiler/CubeValidator.ts b/packages/cubejs-schema-compiler/src/compiler/CubeValidator.ts index 2d8bf36499aef..586b8151f95de 100644 --- a/packages/cubejs-schema-compiler/src/compiler/CubeValidator.ts +++ b/packages/cubejs-schema-compiler/src/compiler/CubeValidator.ts @@ -132,6 +132,11 @@ const BaseDimensionWithoutSubQuery = { enableSuggestions: Joi.boolean().strict(), format: formatSchema, meta: Joi.any(), + values: Joi.when('type', { + is: 'switch', + then: Joi.array().items(Joi.string()), + otherwise: Joi.forbidden() + }), granularities: Joi.when('type', { is: 'time', then: Joi.object().pattern(identifierRegex, @@ -583,6 +588,42 @@ const timeShiftItemOptional = Joi.object({ .xor('name', 'interval') .and('interval', 'type'); +const CaseSchema = Joi.object().keys({ + when: Joi.array().items(Joi.object().keys({ + sql: Joi.func().required(), + label: Joi.alternatives([ + Joi.string(), + Joi.object().keys({ + sql: Joi.func().required() + }) + ]) + })), + else: Joi.object().keys({ + label: Joi.alternatives([ + Joi.string(), + Joi.object().keys({ + sql: Joi.func().required() + }) + ]) + }) +}).required(); + +const SwitchCaseSchema = Joi.object().keys({ + switch: Joi.func().required(), + when: Joi.array().items(Joi.object().keys({ + value: Joi.string().required(), + sql: Joi.func().required() + })), + else: Joi.object().keys({ + sql: Joi.func().required() + }) +}).required(); + +const CaseVariants = Joi.alternatives().try( + CaseSchema, + SwitchCaseSchema +); + const MeasuresSchema = Joi.object().pattern(identifierRegex, Joi.alternatives().conditional(Joi.ref('.multiStage'), [ { is: true, @@ -590,6 +631,7 @@ const MeasuresSchema = Joi.object().pattern(identifierRegex, Joi.alternatives(). multiStage: Joi.boolean().strict(), type: multiStageMeasureType.required(), sql: Joi.func(), // TODO .required(), + case: CaseVariants, groupBy: Joi.func(), reduceBy: Joi.func(), addGroupBy: Joi.func(), @@ -647,53 +689,45 @@ const CalendarTimeShiftItem = Joi.alternatives().try( }) ); -const DimensionsSchema = Joi.object().pattern(identifierRegex, Joi.alternatives().try( - inherit(BaseDimensionWithoutSubQuery, { - case: Joi.object().keys({ - when: Joi.array().items(Joi.object().keys({ - sql: Joi.func().required(), - label: Joi.alternatives([ - Joi.string(), - Joi.object().keys({ - sql: Joi.func().required() - }) - ]) - })), - else: Joi.object().keys({ - label: Joi.alternatives([ - Joi.string(), - Joi.object().keys({ - sql: Joi.func().required() - }) - ]) - }) - }).required() - }), - inherit(BaseDimensionWithoutSubQuery, { - latitude: Joi.object().keys({ - sql: Joi.func().required() - }).required(), - longitude: Joi.object().keys({ - sql: Joi.func().required() - }).required() - }), - inherit(BaseDimension, { - sql: Joi.func().required(), - }), - inherit(BaseDimension, { - multiStage: Joi.boolean().valid(true), - type: Joi.any().valid('number').required(), - sql: Joi.func().required(), - addGroupBy: Joi.func(), - }), - // TODO should be valid only for calendar cubes, but this requires significant refactoring - // of all schemas. Left for the future when we'll switch to zod. - inherit(BaseDimensionWithoutSubQuery, { - type: Joi.any().valid('time').required(), - sql: Joi.func().required(), - timeShift: Joi.array().items(CalendarTimeShiftItem), - }) -)); +const SwitchDimension = Joi.object({ + type: Joi.string().valid('switch').required(), + values: Joi.array().items(Joi.string()).min(1).required() +}); + +const DimensionsSchema = Joi.object().pattern(identifierRegex, Joi.alternatives().conditional(Joi.ref('.type'), { + is: 'switch', + then: SwitchDimension, + otherwise: Joi.alternatives().try( + inherit(BaseDimensionWithoutSubQuery, { + case: CaseVariants.required(), + multiStage: Joi.boolean().strict(), + }), + inherit(BaseDimensionWithoutSubQuery, { + latitude: Joi.object().keys({ + sql: Joi.func().required() + }).required(), + longitude: Joi.object().keys({ + sql: Joi.func().required() + }).required() + }), + inherit(BaseDimension, { + sql: Joi.func().required(), + }), + inherit(BaseDimension, { + multiStage: Joi.boolean().valid(true), + type: Joi.any().valid('number').required(), + sql: Joi.func().required(), + addGroupBy: Joi.func(), + }), + // TODO should be valid only for calendar cubes, but this requires significant refactoring + // of all schemas. Left for the future when we'll switch to zod. + inherit(BaseDimensionWithoutSubQuery, { + type: Joi.any().valid('time').required(), + sql: Joi.func().required(), + timeShift: Joi.array().items(CalendarTimeShiftItem), + }) + ) +})); const SegmentsSchema = Joi.object().pattern(identifierRegex, Joi.object().keys({ aliases: Joi.array().items(Joi.string()), diff --git a/packages/cubejs-schema-compiler/src/compiler/transpilers/CubePropContextTranspiler.ts b/packages/cubejs-schema-compiler/src/compiler/transpilers/CubePropContextTranspiler.ts index e027e2a0dff3b..5c43c7e4248f1 100644 --- a/packages/cubejs-schema-compiler/src/compiler/transpilers/CubePropContextTranspiler.ts +++ b/packages/cubejs-schema-compiler/src/compiler/transpilers/CubePropContextTranspiler.ts @@ -19,6 +19,7 @@ export const transpiledFieldsPatterns: Array = [ /^measures\.[_a-zA-Z][_a-zA-Z0-9]*\.(orderBy|order_by)\.[0-9]+\.sql$/, /^measures\.[_a-zA-Z][_a-zA-Z0-9]*\.(timeShift|time_shift)\.[0-9]+\.(timeDimension|time_dimension)$/, /^measures\.[_a-zA-Z][_a-zA-Z0-9]*\.(reduceBy|reduce_by|groupBy|group_by|addGroupBy|add_group_by)$/, + /^(measures|dimensions)\.[_a-zA-Z][_a-zA-Z0-9]*\.case\.switch$/, /^dimensions\.[_a-zA-Z][_a-zA-Z0-9]*\.(reduceBy|reduce_by|groupBy|group_by|addGroupBy|add_group_by)$/, /^(preAggregations|pre_aggregations)\.[_a-zA-Z][_a-zA-Z0-9]*\.indexes\.[_a-zA-Z][_a-zA-Z0-9]*\.columns$/, /^(preAggregations|pre_aggregations)\.[_a-zA-Z][_a-zA-Z0-9]*\.(timeDimensionReference|timeDimension|time_dimension|segments|dimensions|measures|rollups|segmentReferences|dimensionReferences|measureReferences|rollupReferences)$/, diff --git a/packages/cubejs-schema-compiler/test/integration/postgres/calc-groups.test.ts b/packages/cubejs-schema-compiler/test/integration/postgres/calc-groups.test.ts new file mode 100644 index 0000000000000..5b6410a8f08e7 --- /dev/null +++ b/packages/cubejs-schema-compiler/test/integration/postgres/calc-groups.test.ts @@ -0,0 +1,1711 @@ +import { + getEnv, +} from '@cubejs-backend/shared'; +import { prepareYamlCompiler } from '../../unit/PrepareCompiler'; +import { dbRunner } from './PostgresDBRunner'; + +describe('Calc-Groups', () => { + jest.setTimeout(200000); + + const { compiler, joinGraph, cubeEvaluator } = prepareYamlCompiler(` +cubes: + - name: orders + sql: > + SELECT 9 as ID, 'completed' as STATUS, 100.0 as amount_usd, 97.4 as amount_eur, 80.6 as amount_gbp, '2022-01-12T20:00:00.000Z'::timestamptz as CREATED_AT + union all + SELECT 10 as ID, 'completed' as STATUS, 10.0 as amount_usd, 9.74 as amount_eur, 8.06 as amount_gbp, '2023-01-12T20:00:00.000Z'::timestamptz as CREATED_AT + union all + SELECT 11 as ID, 'completed' as STATUS, 1000.0 as amount_usd, 974 as amount_eur, 806 as amount_gbp,'2024-01-14T20:00:00.000Z'::timestamptz as CREATED_AT + union all + SELECT 12 as ID, 'completed' as STATUS, 30.0 as amount_usd, 28 as amount_eur, 22 as amount_gbp,'2024-02-14T20:00:00.000Z'::timestamptz as CREATED_AT + union all + SELECT 13 as ID, 'completed' as STATUS, 40.0 as amount_usd, 38 as amount_eur, 33 as amount_gbp, '2025-03-14T20:00:00.000Z'::timestamptz as CREATED_AT + joins: + - name: line_items + sql: "{CUBE}.ID = {line_items}.order_id" + relationship: many_to_one + + dimensions: + - name: id + sql: ID + type: number + primary_key: true + + - name: status + sql: STATUS + type: string + + - name: date + sql: CREATED_AT + type: time + + - name: amount + sql: '{line_items.total_amount}' + type: number + sub_query: true + + - name: currency + type: switch + values: + - USD + - EUR + - GBP + + - name: currency_ref + type: string + sql: "{currency}" + + + - name: strategy + type: switch + values: + - A + - B + + - name: strategy_ref + type: string + sql: "{strategy}" + + - name: currency_and_stategy + type: string + sql: "CONCAT({currency}, '-', {strategy})" + + - name: currency_and_strategy_ref + type: string + sql: "{currency_and_stategy}" + + - name: currency_full_name + type: string + case: + switch: "{CUBE.currency}" + when: + - value: USD + sql: "'dollars'" + - value: EUR + sql: "'euros'" + else: + sql: "'unknown'" + + measures: + - name: count + type: count + + - name: completed_count + type: count + filters: + - sql: "{CUBE}.STATUS = 'completed'" + + - name: amount_usd + type: sum + sql: amount_usd + + - name: amount_eur + type: sum + sql: amount_eur + + - name: amount_gbp + type: sum + sql: amount_gbp + + - name: amount_in_currency + type: number + multi_stage: true + case: + switch: "{CUBE.currency}" + when: + - value: USD + sql: "{CUBE.amount_usd}" + - value: EUR + sql: "{CUBE.amount_eur}" + else: + sql: "{CUBE.amount_gbp}" + + - name: amount_in_currency_ref + type: number + sql: "{CUBE.amount_in_currency}" + + - name: returned_count + type: count + filters: + - sql: "{CUBE}.STATUS = 'returned'" + + - name: amount_in_currency_percent_of_usd + type: number + sql: "FLOOR({CUBE.amount_in_currency_ref} / {CUBE.amount_usd} * 100)" + + + - name: return_rate + type: number + sql: "({returned_count} / NULLIF({completed_count}, 0)) * 100.0" + description: "Percentage of returned orders out of completed, exclude just placed orders." + format: percent + + - name: total_amount + sql: '{CUBE.amount}' + type: sum + + - name: revenue + sql: "CASE WHEN {CUBE}.status = 'completed' THEN {CUBE.amount} END" + type: sum + format: currency + + - name: average_order_value + sql: '{CUBE.amount}' + type: avg + + - name: revenue_1_y_ago + sql: "{revenue}" + multi_stage: true + type: number + format: currency + time_shift: + - time_dimension: date + interval: 1 year + type: prior + - time_dimension: orders_view.date + interval: 1 year + type: prior + + - name: cagr_1_y + sql: "(({revenue} / {revenue_1_y_ago}) - 1)" + type: number + format: percent + description: "Annual CAGR, year over year growth in revenue" + + - name: line_items + sql: > + SELECT 9 as ID, '2024-01-12T20:00:00.000Z'::timestamptz as CREATED_AT, 9 as ORDER_ID, 11 as PRODUCT_ID + union all + SELECT 10 as ID, '2024-01-12T20:00:00.000Z'::timestamptz as CREATED_AT, 10 as ORDER_ID, 10 as PRODUCT_ID + union all + SELECT 11 as ID, '2024-01-12T20:00:00.000Z'::timestamptz as CREATED_AT, 10 as ORDER_ID, 11 as PRODUCT_ID + union all + SELECT 12 as ID, '2024-01-12T20:00:00.000Z'::timestamptz as CREATED_AT, 11 as ORDER_ID, 10 as PRODUCT_ID + union all + SELECT 13 as ID, '2024-01-12T20:00:00.000Z'::timestamptz as CREATED_AT, 11 as ORDER_ID, 10 as PRODUCT_ID + union all + SELECT 14 as ID, '2024-01-12T20:00:00.000Z'::timestamptz as CREATED_AT, 12 as ORDER_ID, 10 as PRODUCT_ID + union all + SELECT 15 as ID, '2024-01-12T20:00:00.000Z'::timestamptz as CREATED_AT, 13 as ORDER_ID, 11 as PRODUCT_ID + public: false + + joins: + - name: products + sql: "{CUBE}.PRODUCT_ID = {products}.ID" + relationship: many_to_one + + dimensions: + - name: id + sql: ID + type: number + primary_key: true + + - name: created_at + sql: CREATED_AT + type: time + + - name: price + sql: "{products.price}" + type: number + + measures: + - name: count + type: count + + - name: total_amount + sql: "{price}" + type: sum + + - name: products + sql: > + SELECT 10 as ID, 'some category' as PRODUCT_CATEGORY, 'some name' as NAME, 10 as PRICE + union all + SELECT 11 as ID, 'some category' as PRODUCT_CATEGORY, 'some name' as NAME, 5 as PRICE + public: false + description: > + Products and categories in our e-commerce store. + + dimensions: + - name: id + sql: ID + type: number + primary_key: true + + - name: product_category + sql: PRODUCT_CATEGORY + type: string + + - name: name + sql: NAME + type: string + + - name: price + sql: PRICE + type: number + + measures: + - name: count + type: count + + - name: source_a + sql: > + SELECT 10 as ID, 'some category' as PRODUCT_CATEGORY, 'some name' as NAME, 100 as PRICE_USD, 0 as PRICE_EUR, '2022-01-12T20:00:00.000Z'::timestamptz as CREATED_AT + union all + SELECT 11 as ID, 'some category' as PRODUCT_CATEGORY, 'some name' as NAME, 500 as PRICE_USD, 0 as PRICE_EUR, '2022-01-14T20:00:00.000Z'::timestamptz as CREATED_AT + union all + SELECT 12 as ID, 'some category A' as PRODUCT_CATEGORY, 'some name' as NAME, 200 as PRICE_USD, 0 as PRICE_EUR, '2022-02-12T20:00:00.000Z'::timestamptz as CREATED_AT + union all + SELECT 13 as ID, 'some category A' as PRODUCT_CATEGORY, 'some name' as NAME, 300 as PRICE_USD, 0 as PRICE_EUR, '2022-03-14T20:00:00.000Z'::timestamptz as CREATED_AT + public: false + + dimensions: + - name: pk + type: number + sql: ID + primary_key: true + + - name: product_category + sql: PRODUCT_CATEGORY + type: string + + - name: created_at + sql: CREATED_AT + type: time + + measures: + - name: count + type: 'count' + + - name: price_usd + type: 'sum' + sql: PRICE_USD + + - name: price_eur + type: 'sum' + sql: PRICE_EUR + + + - name: source_b + sql: > + SELECT 10 as ID, 'some category' as PRODUCT_CATEGORY, 'some name' as NAME, 0 as PRICE_USD, 100 as PRICE_EUR, '2022-01-12T20:00:00.000Z'::timestamptz as CREATED_AT + union all + SELECT 11 as ID, 'some category' as PRODUCT_CATEGORY, 'some name' as NAME, 0 as PRICE_USD, 500 as PRICE_EUR, '2022-02-12T20:00:00.000Z'::timestamptz as CREATED_AT + union all + SELECT 12 as ID, 'some category B' as PRODUCT_CATEGORY, 'some name' as NAME, 0 as PRICE_USD, 200 as PRICE_EUR, '2022-02-15T20:00:00.000Z'::timestamptz as CREATED_AT + union all + SELECT 13 as ID, 'some category B' as PRODUCT_CATEGORY, 'some name' as NAME, 0 as PRICE_USD, 300 as PRICE_EUR, '2022-03-12T20:00:00.000Z'::timestamptz as CREATED_AT + union all + SELECT 14 as ID, 'some category B' as PRODUCT_CATEGORY, 'some name' as NAME, 0 as PRICE_USD, 300 as PRICE_EUR, '2022-04-12T20:00:00.000Z'::timestamptz as CREATED_AT + public: false + + dimensions: + - name: pk + type: number + sql: ID + primary_key: true + + - name: product_category + sql: PRODUCT_CATEGORY + type: string + + - name: created_at + sql: CREATED_AT + type: time + + measures: + - name: count + type: 'count' + + - name: price_usd + type: 'sum' + sql: PRICE_USD + + - name: price_eur + type: 'sum' + sql: PRICE_EUR + +views: + + - name: source + dimensions: + - name: source + type: switch + values: ["A", "B"] + + - name: currency + type: switch + values: ["USD", "EUR"] + + - name: product_category + type: string + multi_stage: true + case: + switch: "{CUBE.source}" + when: + - value: A + sql: "{source_a.product_category}" + - value: B + sql: "{source_b.product_category}" + else: + sql: "{source_a.product_category}" + + - name: product_category_ext + type: string + multi_stage: true + case: + switch: "{CUBE.currency}" + when: + - value: USD + sql: "CONCAT({source.product_category}, '-', 'USD', '-', {source.currency})" + - value: EUR + sql: "CONCAT({source.product_category}, '-', 'EUR', '-', {source.currency})" + else: + sql: "" + + - name: created_at + type: time + multi_stage: true + case: + switch: "{CUBE.source}" + when: + - value: A + sql: "{source_a.created_at}" + - value: B + sql: "{source_b.created_at}" + else: + sql: "{source_a.created_at}" + + + measures: + - name: count + type: sum + multi_stage: true + case: + switch: "{CUBE.source}" + when: + - value: A + sql: "{source_a.count}" + - value: B + sql: "{source_b.count}" + else: + sql: "{source_a.count}" + + - name: price_eur + type: sum + multi_stage: true + case: + switch: "{CUBE.source}" + when: + - value: A + sql: "{source_a.price_eur}" + - value: B + sql: "{source_b.price_eur}" + else: + sql: "{source_a.price_eur}" + + - name: price_usd + type: sum + multi_stage: true + case: + switch: "{CUBE.source}" + when: + - value: A + sql: "{source_a.price_usd}" + - value: B + sql: "{source_b.price_usd}" + else: + sql: "{source_a.price_usd}" + + - name: price + type: sum + multi_stage: true + case: + switch: "{CUBE.currency}" + when: + - value: USD + sql: "{CUBE.price_usd}" + - value: EUR + sql: "{CUBE.price_eur}" + else: + sql: "{CUBE.price_usd}" + + + - name: orders_view + cubes: + - join_path: orders + includes: + - date + - revenue + - cagr_1_y + - return_rate + + - join_path: line_items.products + prefix: true + includes: + - product_category + + `); + + if (getEnv('nativeSqlPlanner')) { + it('basic cross join 1', async () => dbRunner.runQueryTest({ + dimensions: ['orders.currency'], + timeDimensions: [ + { + dimension: 'orders.date', + granularity: 'year' + } + ], + timezone: 'UTC' + }, [ + { + orders__currency: 'EUR', + orders__date_year: '2022-01-01T00:00:00.000Z' + }, + { + orders__currency: 'GBP', + orders__date_year: '2022-01-01T00:00:00.000Z' + }, + { + orders__currency: 'USD', + orders__date_year: '2022-01-01T00:00:00.000Z' + }, + { + orders__currency: 'EUR', + orders__date_year: '2023-01-01T00:00:00.000Z' + }, + { + orders__currency: 'GBP', + orders__date_year: '2023-01-01T00:00:00.000Z' + }, + { + orders__currency: 'USD', + orders__date_year: '2023-01-01T00:00:00.000Z' + }, + { + orders__currency: 'EUR', + orders__date_year: '2024-01-01T00:00:00.000Z' + }, + { + orders__currency: 'GBP', + orders__date_year: '2024-01-01T00:00:00.000Z' + }, + { + orders__currency: 'USD', + orders__date_year: '2024-01-01T00:00:00.000Z' + }, + { + orders__currency: 'EUR', + orders__date_year: '2025-01-01T00:00:00.000Z' + }, + { + orders__currency: 'GBP', + orders__date_year: '2025-01-01T00:00:00.000Z' + }, + { + orders__currency: 'USD', + orders__date_year: '2025-01-01T00:00:00.000Z' + } + ], + { joinGraph, cubeEvaluator, compiler })); + + it('basic cross join by proxy dim', async () => dbRunner.runQueryTest({ + dimensions: ['orders.currency_ref'], + timeDimensions: [ + { + dimension: 'orders.date', + granularity: 'year' + } + ], + timezone: 'UTC' + }, [ + { + orders__currency_ref: 'EUR', + orders__date_year: '2022-01-01T00:00:00.000Z' + }, + { + orders__currency_ref: 'GBP', + orders__date_year: '2022-01-01T00:00:00.000Z' + }, + { + orders__currency_ref: 'USD', + orders__date_year: '2022-01-01T00:00:00.000Z' + }, + { + orders__currency_ref: 'EUR', + orders__date_year: '2023-01-01T00:00:00.000Z' + }, + { + orders__currency_ref: 'GBP', + orders__date_year: '2023-01-01T00:00:00.000Z' + }, + { + orders__currency_ref: 'USD', + orders__date_year: '2023-01-01T00:00:00.000Z' + }, + { + orders__currency_ref: 'EUR', + orders__date_year: '2024-01-01T00:00:00.000Z' + }, + { + orders__currency_ref: 'GBP', + orders__date_year: '2024-01-01T00:00:00.000Z' + }, + { + orders__currency_ref: 'USD', + orders__date_year: '2024-01-01T00:00:00.000Z' + }, + { + orders__currency_ref: 'EUR', + orders__date_year: '2025-01-01T00:00:00.000Z' + }, + { + orders__currency_ref: 'GBP', + orders__date_year: '2025-01-01T00:00:00.000Z' + }, + { + orders__currency_ref: 'USD', + orders__date_year: '2025-01-01T00:00:00.000Z' + } + ], + { joinGraph, cubeEvaluator, compiler })); + + it('basic double cross join', async () => dbRunner.runQueryTest({ + dimensions: ['orders.currency', 'orders.strategy'], + timeDimensions: [ + { + dimension: 'orders.date', + granularity: 'year', + dateRange: ['2024-01-01', '2026-01-01'] + } + ], + timezone: 'UTC', + order: [{ + id: 'orders.date' + }, { + id: 'orders.currency' + }, { + id: 'orders.strategy' + }, + ], + }, [ + { + orders__currency: 'EUR', + orders__strategy: 'A', + orders__date_year: '2024-01-01T00:00:00.000Z' + }, + { + orders__currency: 'EUR', + orders__strategy: 'B', + orders__date_year: '2024-01-01T00:00:00.000Z' + }, + { + orders__currency: 'GBP', + orders__strategy: 'A', + orders__date_year: '2024-01-01T00:00:00.000Z' + }, + { + orders__currency: 'GBP', + orders__strategy: 'B', + orders__date_year: '2024-01-01T00:00:00.000Z' + }, + { + orders__currency: 'USD', + orders__strategy: 'A', + orders__date_year: '2024-01-01T00:00:00.000Z' + }, + { + orders__currency: 'USD', + orders__strategy: 'B', + orders__date_year: '2024-01-01T00:00:00.000Z' + }, + { + orders__currency: 'EUR', + orders__strategy: 'A', + orders__date_year: '2025-01-01T00:00:00.000Z' + }, + { + orders__currency: 'EUR', + orders__strategy: 'B', + orders__date_year: '2025-01-01T00:00:00.000Z' + }, + { + orders__currency: 'GBP', + orders__strategy: 'A', + orders__date_year: '2025-01-01T00:00:00.000Z' + }, + { + orders__currency: 'GBP', + orders__strategy: 'B', + orders__date_year: '2025-01-01T00:00:00.000Z' + }, + { + orders__currency: 'USD', + orders__strategy: 'A', + orders__date_year: '2025-01-01T00:00:00.000Z' + }, + { + orders__currency: 'USD', + orders__strategy: 'B', + orders__date_year: '2025-01-01T00:00:00.000Z' + } + ], + { joinGraph, cubeEvaluator, compiler })); + + it('basic double cross join by proxy', async () => dbRunner.runQueryTest({ + dimensions: ['orders.currency_and_strategy_ref'], + timeDimensions: [ + { + dimension: 'orders.date', + granularity: 'year', + dateRange: ['2024-01-01', '2026-01-01'] + } + ], + timezone: 'UTC', + order: [{ + id: 'orders.date' + }, { + id: 'orders.currency' + }, { + id: 'orders.strategy' + }, + ], + }, [ + { + orders__currency_and_strategy_ref: 'EUR-A', + orders__date_year: '2024-01-01T00:00:00.000Z' + }, + { + orders__currency_and_strategy_ref: 'EUR-B', + orders__date_year: '2024-01-01T00:00:00.000Z' + }, + { + orders__currency_and_strategy_ref: 'GBP-A', + orders__date_year: '2024-01-01T00:00:00.000Z' + }, + { + orders__currency_and_strategy_ref: 'GBP-B', + orders__date_year: '2024-01-01T00:00:00.000Z' + }, + { + orders__currency_and_strategy_ref: 'USD-A', + orders__date_year: '2024-01-01T00:00:00.000Z' + }, + { + orders__currency_and_strategy_ref: 'USD-B', + orders__date_year: '2024-01-01T00:00:00.000Z' + }, + { + orders__currency_and_strategy_ref: 'EUR-A', + orders__date_year: '2025-01-01T00:00:00.000Z' + }, + { + orders__currency_and_strategy_ref: 'EUR-B', + orders__date_year: '2025-01-01T00:00:00.000Z' + }, + { + orders__currency_and_strategy_ref: 'GBP-A', + orders__date_year: '2025-01-01T00:00:00.000Z' + }, + { + orders__currency_and_strategy_ref: 'GBP-B', + orders__date_year: '2025-01-01T00:00:00.000Z' + }, + { + orders__currency_and_strategy_ref: 'USD-A', + orders__date_year: '2025-01-01T00:00:00.000Z' + }, + { + orders__currency_and_strategy_ref: 'USD-B', + orders__date_year: '2025-01-01T00:00:00.000Z' + } + ], + { joinGraph, cubeEvaluator, compiler })); + + it('basic cross join with measure', async () => dbRunner.runQueryTest({ + dimensions: ['orders.strategy'], + measures: ['orders.revenue'], + timeDimensions: [ + { + dimension: 'orders.date', + granularity: 'year' + } + ], + timezone: 'UTC', + order: [{ + id: 'orders.date' + }, { + id: 'orders.currency' + }, + ], + }, [ + { + orders__date_year: '2022-01-01T00:00:00.000Z', + orders__strategy: 'A', + orders__revenue: '5', + }, + { + orders__date_year: '2022-01-01T00:00:00.000Z', + orders__strategy: 'B', + orders__revenue: '5', + }, + { + orders__date_year: '2023-01-01T00:00:00.000Z', + orders__strategy: 'A', + orders__revenue: '15', + }, + { + orders__date_year: '2023-01-01T00:00:00.000Z', + orders__strategy: 'B', + orders__revenue: '15', + }, + { + orders__date_year: '2024-01-01T00:00:00.000Z', + orders__strategy: 'A', + orders__revenue: '30', + }, + { + orders__date_year: '2024-01-01T00:00:00.000Z', + orders__strategy: 'B', + orders__revenue: '30', + }, + { + orders__date_year: '2025-01-01T00:00:00.000Z', + orders__strategy: 'A', + orders__revenue: '5', + }, + { + orders__date_year: '2025-01-01T00:00:00.000Z', + orders__strategy: 'B', + orders__revenue: '5', + } + ], + { joinGraph, cubeEvaluator, compiler })); + + it('basic cross join with filters', async () => { + const sqlAndParams = await dbRunner.runQueryTest({ + dimensions: ['orders.strategy'], + measures: ['orders.revenue'], + timeDimensions: [ + { + dimension: 'orders.date', + granularity: 'year' + } + ], + filters: [ + { dimension: 'orders.strategy', operator: 'equals', values: ['B'] } + ], + timezone: 'UTC', + order: [{ + id: 'orders.date' + }, { + id: 'orders.currency' + }, + ], + }, [ + { + orders__date_year: '2022-01-01T00:00:00.000Z', + orders__strategy: 'B', + orders__revenue: '5', + }, + { + orders__date_year: '2023-01-01T00:00:00.000Z', + orders__strategy: 'B', + orders__revenue: '15', + }, + { + orders__date_year: '2024-01-01T00:00:00.000Z', + orders__strategy: 'B', + orders__revenue: '30', + }, + { + orders__date_year: '2025-01-01T00:00:00.000Z', + orders__strategy: 'B', + orders__revenue: '5', + } + ], + { joinGraph, cubeEvaluator, compiler }); + + expect(sqlAndParams[0]).not.toMatch(/CROSS.+JOIN/); + }); + + it('basic cross join with filters proxy dim', async () => { + const sqlAndParams = await dbRunner.runQueryTest({ + dimensions: ['orders.strategy_ref'], + measures: ['orders.revenue'], + timeDimensions: [ + { + dimension: 'orders.date', + granularity: 'year' + } + ], + filters: [ + { dimension: 'orders.strategy_ref', operator: 'equals', values: ['B'] } + ], + timezone: 'UTC', + order: [{ + id: 'orders.date' + }, { + id: 'orders.currency' + }, + ], + }, [ + { + orders__date_year: '2022-01-01T00:00:00.000Z', + orders__strategy_ref: 'B', + orders__revenue: '5', + }, + { + orders__date_year: '2023-01-01T00:00:00.000Z', + orders__strategy_ref: 'B', + orders__revenue: '15', + }, + { + orders__date_year: '2024-01-01T00:00:00.000Z', + orders__strategy_ref: 'B', + orders__revenue: '30', + }, + { + orders__date_year: '2025-01-01T00:00:00.000Z', + orders__strategy_ref: 'B', + orders__revenue: '5', + } + ], + { joinGraph, cubeEvaluator, compiler }); + + expect(sqlAndParams[0]).not.toMatch(/CROSS.+JOIN/); + }); + + it('dimension switch expression simple', async () => dbRunner.runQueryTest({ + dimensions: ['orders.currency', 'orders.currency_full_name'], + measures: ['orders.revenue'], + timeDimensions: [ + { + dimension: 'orders.date', + granularity: 'year', + dateRange: ['2024-01-01', '2026-01-01'] + } + ], + timezone: 'UTC', + order: [{ + id: 'orders.date' + }, { + id: 'orders.currency' + }, + ], + }, [ + { + orders__currency: 'EUR', + orders__currency_full_name: 'euros', + orders__date_year: '2024-01-01T00:00:00.000Z', + orders__revenue: '30' + }, + { + orders__currency: 'GBP', + orders__currency_full_name: 'unknown', + orders__date_year: '2024-01-01T00:00:00.000Z', + orders__revenue: '30' + }, + { + orders__currency: 'USD', + orders__currency_full_name: 'dollars', + orders__date_year: '2024-01-01T00:00:00.000Z', + orders__revenue: '30' + }, + { + orders__currency: 'EUR', + orders__currency_full_name: 'euros', + orders__date_year: '2025-01-01T00:00:00.000Z', + orders__revenue: '5' + }, + { + orders__currency: 'GBP', + orders__currency_full_name: 'unknown', + orders__date_year: '2025-01-01T00:00:00.000Z', + orders__revenue: '5' + }, + { + orders__currency: 'USD', + orders__currency_full_name: 'dollars', + orders__date_year: '2025-01-01T00:00:00.000Z', + orders__revenue: '5' + } + ], + { joinGraph, cubeEvaluator, compiler })); + + it('measure switch cross join', async () => dbRunner.runQueryTest({ + dimensions: ['orders.currency'], + measures: ['orders.amount_usd', 'orders.amount_in_currency'], + timeDimensions: [ + { + dimension: 'orders.date', + granularity: 'year', + dateRange: ['2024-01-01', '2026-01-01'] + } + ], + timezone: 'UTC', + order: [{ + id: 'orders.date' + }, { + id: 'orders.currency' + }, + ], + }, [ + { + orders__currency: 'EUR', + orders__date_year: '2024-01-01T00:00:00.000Z', + orders__amount_usd: '1030.0', + orders__amount_in_currency: '1002' + }, + { + orders__currency: 'GBP', + orders__date_year: '2024-01-01T00:00:00.000Z', + orders__amount_usd: '1030.0', + orders__amount_in_currency: '828' + }, + { + orders__currency: 'USD', + orders__date_year: '2024-01-01T00:00:00.000Z', + orders__amount_usd: '1030.0', + orders__amount_in_currency: '1030.0' + }, + { + orders__currency: 'EUR', + orders__date_year: '2025-01-01T00:00:00.000Z', + orders__amount_usd: '40.0', + orders__amount_in_currency: '38' + }, + { + orders__currency: 'GBP', + orders__date_year: '2025-01-01T00:00:00.000Z', + orders__amount_usd: '40.0', + orders__amount_in_currency: '33' + }, + { + orders__currency: 'USD', + orders__date_year: '2025-01-01T00:00:00.000Z', + orders__amount_usd: '40.0', + orders__amount_in_currency: '40.0' + } + ], + { joinGraph, cubeEvaluator, compiler })); + + it('complex measure switch cross join', async () => dbRunner.runQueryTest({ + dimensions: ['orders.currency'], + measures: ['orders.amount_in_currency_percent_of_usd'], + timeDimensions: [ + { + dimension: 'orders.date', + granularity: 'year', + dateRange: ['2024-01-01', '2026-01-01'] + } + ], + timezone: 'UTC', + order: [{ + id: 'orders.date' + }, { + id: 'orders.currency' + }, + ], + }, [ + { + orders__currency: 'EUR', + orders__date_year: '2024-01-01T00:00:00.000Z', + orders__amount_in_currency_percent_of_usd: '97' + }, + { + orders__currency: 'GBP', + orders__date_year: '2024-01-01T00:00:00.000Z', + orders__amount_in_currency_percent_of_usd: '80' + }, + { + orders__currency: 'USD', + orders__date_year: '2024-01-01T00:00:00.000Z', + orders__amount_in_currency_percent_of_usd: '100' + }, + { + orders__currency: 'EUR', + orders__date_year: '2025-01-01T00:00:00.000Z', + orders__amount_in_currency_percent_of_usd: '95' + }, + { + orders__currency: 'GBP', + orders__date_year: '2025-01-01T00:00:00.000Z', + orders__amount_in_currency_percent_of_usd: '82' + }, + { + orders__currency: 'USD', + orders__date_year: '2025-01-01T00:00:00.000Z', + orders__amount_in_currency_percent_of_usd: '100' + } + ], + { joinGraph, cubeEvaluator, compiler })); + + it('measure switch with filter', async () => { + const sqlAndParams = await dbRunner.runQueryTest({ + dimensions: ['orders.currency'], + measures: ['orders.amount_usd', 'orders.amount_in_currency'], + timeDimensions: [ + { + dimension: 'orders.date', + granularity: 'year', + dateRange: ['2024-01-01', '2026-01-01'] + } + ], + filters: [ + { dimension: 'orders.currency', operator: 'equals', values: ['EUR'] } + ], + timezone: 'UTC', + order: [{ + id: 'orders.date' + }, { + id: 'orders.currency' + }, + ], + }, [ + { + orders__currency: 'EUR', + orders__date_year: '2024-01-01T00:00:00.000Z', + orders__amount_usd: '1030.0', + orders__amount_in_currency: '1002' + }, + { + orders__currency: 'EUR', + orders__date_year: '2025-01-01T00:00:00.000Z', + orders__amount_usd: '40.0', + orders__amount_in_currency: '38' + }, + ], + { joinGraph, cubeEvaluator, compiler }); + + expect(sqlAndParams[0]).not.toMatch(/CASE/); + expect(sqlAndParams[0]).not.toMatch(/CROSS.+JOIN/); + }); + + it('complex measure switch with filter', async () => { + const sqlAndParams = await dbRunner.runQueryTest({ + dimensions: ['orders.currency'], + measures: ['orders.amount_in_currency_percent_of_usd'], + timeDimensions: [ + { + dimension: 'orders.date', + granularity: 'year', + dateRange: ['2024-01-01', '2026-01-01'] + } + ], + filters: [ + { dimension: 'orders.currency', operator: 'equals', values: ['EUR'] } + ], + timezone: 'UTC', + order: [{ + id: 'orders.date' + }, { + id: 'orders.currency' + }, + ], + }, [ + { + orders__currency: 'EUR', + orders__date_year: '2024-01-01T00:00:00.000Z', + orders__amount_in_currency_percent_of_usd: '97' + }, + { + orders__currency: 'EUR', + orders__date_year: '2025-01-01T00:00:00.000Z', + orders__amount_in_currency_percent_of_usd: '95' + }, + ], + { joinGraph, cubeEvaluator, compiler }); + + expect(sqlAndParams[0]).not.toMatch(/CASE/); + expect(sqlAndParams[0]).not.toMatch(/CROSS.+JOIN/); + }); + it('source switch cross join', async () => { + await dbRunner.runQueryTest({ + dimensions: ['source.source'], + measures: ['source.count'], + order: [{ + id: 'source.source' + } + ], + }, [ + { source__source: 'A', source__count: '4' }, + { source__source: 'B', source__count: '5' } + ], + { joinGraph, cubeEvaluator, compiler }); + }); + it('source product_category cross join', async () => { + await dbRunner.runQueryTest({ + dimensions: ['source.product_category'], + order: [{ + id: 'source.product_category' + } + ], + }, [ + { source__product_category: 'some category' }, + { source__product_category: 'some category A' }, + { source__product_category: 'some category B' } + ], + { joinGraph, cubeEvaluator, compiler }); + }); + it('source product_category and created_at cross join', async () => { + await dbRunner.runQueryTest({ + dimensions: ['source.product_category'], + timeDimensions: [ + { + dimension: 'source.created_at', + granularity: 'month' + } + ], + timezone: 'UTC', + order: [ + { + id: 'source.created_at' + }, + { + id: 'source.product_category' + } + ], + }, [ + { + source__product_category: 'some category', + source__created_at_month: '2022-01-01T00:00:00.000Z' + }, + { + source__product_category: 'some category', + source__created_at_month: '2022-02-01T00:00:00.000Z' + }, + { + source__product_category: 'some category A', + source__created_at_month: '2022-02-01T00:00:00.000Z' + }, + { + source__product_category: 'some category B', + source__created_at_month: '2022-02-01T00:00:00.000Z' + }, + { + source__product_category: 'some category A', + source__created_at_month: '2022-03-01T00:00:00.000Z' + }, + { + source__product_category: 'some category B', + source__created_at_month: '2022-03-01T00:00:00.000Z' + }, + { + source__product_category: 'some category B', + source__created_at_month: '2022-04-01T00:00:00.000Z' + } + ], + { joinGraph, cubeEvaluator, compiler }); + }); + + it('source product_category_ext and created_at cross join', async () => { + await dbRunner.runQueryTest({ + dimensions: ['source.product_category_ext'], + timeDimensions: [ + { + dimension: 'source.created_at', + granularity: 'month' + } + ], + timezone: 'UTC', + order: [ + { + id: 'source.created_at' + }, + { + id: 'source.product_category_ext' + } + ], + }, [ + { + source__product_category_ext: 'some category-EUR-EUR', + source__created_at_month: '2022-01-01T00:00:00.000Z' + }, + { + source__product_category_ext: 'some category-USD-USD', + source__created_at_month: '2022-01-01T00:00:00.000Z' + }, + { + source__product_category_ext: 'some category A-EUR-EUR', + source__created_at_month: '2022-02-01T00:00:00.000Z' + }, + { + source__product_category_ext: 'some category A-USD-USD', + source__created_at_month: '2022-02-01T00:00:00.000Z' + }, + { + source__product_category_ext: 'some category B-EUR-EUR', + source__created_at_month: '2022-02-01T00:00:00.000Z' + }, + { + source__product_category_ext: 'some category B-USD-USD', + source__created_at_month: '2022-02-01T00:00:00.000Z' + }, + { + source__product_category_ext: 'some category-EUR-EUR', + source__created_at_month: '2022-02-01T00:00:00.000Z' + }, + { + source__product_category_ext: 'some category-USD-USD', + source__created_at_month: '2022-02-01T00:00:00.000Z' + }, + { + source__product_category_ext: 'some category A-EUR-EUR', + source__created_at_month: '2022-03-01T00:00:00.000Z' + }, + { + source__product_category_ext: 'some category A-USD-USD', + source__created_at_month: '2022-03-01T00:00:00.000Z' + }, + { + source__product_category_ext: 'some category B-EUR-EUR', + source__created_at_month: '2022-03-01T00:00:00.000Z' + }, + { + source__product_category_ext: 'some category B-USD-USD', + source__created_at_month: '2022-03-01T00:00:00.000Z' + }, + { + source__product_category_ext: 'some category B-EUR-EUR', + source__created_at_month: '2022-04-01T00:00:00.000Z' + }, + { + source__product_category_ext: 'some category B-USD-USD', + source__created_at_month: '2022-04-01T00:00:00.000Z' + } + ], + { joinGraph, cubeEvaluator, compiler }); + }); + + it('source product_category_ext filter', async () => { + await dbRunner.runQueryTest({ + dimensions: ['source.product_category'], + measures: ['source.price'], + filters: [ + { dimension: 'source.product_category_ext', operator: 'equals', values: ['some category B-EUR-EUR'] } + ], + timezone: 'UTC', + order: [ + { + id: 'source.created_at' + }, + { + id: 'source.product_category_ext' + } + ], + }, [ + { + source__product_category: 'some category B', + source__price: '800' + }, + ], + { joinGraph, cubeEvaluator, compiler }); + }); + + it('source switch cross join without dimension', async () => { + await dbRunner.runQueryTest({ + dimensions: ['source.product_category'], + measures: ['source.count'], + order: [{ + id: 'source.product_category' + } + ], + }, [ + { source__product_category: 'some category', source__count: '4' }, + { source__product_category: 'some category A', source__count: '2' }, + { source__product_category: 'some category B', source__count: '3' } + ], + { joinGraph, cubeEvaluator, compiler }); + }); + it('source full switch', async () => { + await dbRunner.runQueryTest({ + dimensions: ['source.currency', 'source.product_category'], + measures: ['source.price'], + order: [{ + id: 'source.product_category' + }, + { + id: 'source.currency' + } + ], + }, [ + { + source__currency: 'EUR', + source__product_category: 'some category', + source__price: '600' + }, + { + source__currency: 'USD', + source__product_category: 'some category', + source__price: '600' + }, + { + source__currency: 'EUR', + source__product_category: 'some category A', + source__price: '0' + }, + { + source__currency: 'USD', + source__product_category: 'some category A', + source__price: '500' + }, + { + source__currency: 'EUR', + source__product_category: 'some category B', + source__price: '800' + }, + { + source__currency: 'USD', + source__product_category: 'some category B', + source__price: '0' + } + ], + { joinGraph, cubeEvaluator, compiler }); + }); + it('source full switch - td day', async () => { + await dbRunner.runQueryTest({ + dimensions: ['source.currency', 'source.product_category'], + timeDimensions: [ + { + dimension: 'source.created_at', + granularity: 'month', + } + ], + timezone: 'UTC', + order: [{ + id: 'source.created_at' + }, + { + id: 'source.product_category' + }, + { + id: 'source.currency' + } + ], + }, [ + { + source__product_category: 'some category', + source__created_at_month: '2022-01-01T00:00:00.000Z', + source__currency: 'EUR', + }, + { + source__product_category: 'some category', + source__created_at_month: '2022-01-01T00:00:00.000Z', + source__currency: 'USD', + }, + { + source__product_category: 'some category', + source__created_at_month: '2022-02-01T00:00:00.000Z', + source__currency: 'EUR', + }, + { + source__product_category: 'some category', + source__created_at_month: '2022-02-01T00:00:00.000Z', + source__currency: 'USD', + }, + { + source__product_category: 'some category A', + source__created_at_month: '2022-02-01T00:00:00.000Z', + source__currency: 'EUR', + }, + { + source__product_category: 'some category A', + source__created_at_month: '2022-02-01T00:00:00.000Z', + source__currency: 'USD', + }, + { + source__product_category: 'some category B', + source__created_at_month: '2022-02-01T00:00:00.000Z', + source__currency: 'EUR', + }, + { + source__product_category: 'some category B', + source__created_at_month: '2022-02-01T00:00:00.000Z', + source__currency: 'USD', + }, + { + source__product_category: 'some category A', + source__created_at_month: '2022-03-01T00:00:00.000Z', + source__currency: 'EUR', + }, + { + source__product_category: 'some category A', + source__created_at_month: '2022-03-01T00:00:00.000Z', + source__currency: 'USD', + }, + { + source__product_category: 'some category B', + source__created_at_month: '2022-03-01T00:00:00.000Z', + source__currency: 'EUR', + }, + { + source__product_category: 'some category B', + source__created_at_month: '2022-03-01T00:00:00.000Z', + source__currency: 'USD', + }, + { + source__product_category: 'some category B', + source__created_at_month: '2022-04-01T00:00:00.000Z', + source__currency: 'EUR', + }, + { + source__product_category: 'some category B', + source__created_at_month: '2022-04-01T00:00:00.000Z', + source__currency: 'USD', + } + ], + { joinGraph, cubeEvaluator, compiler }); + }); + it('source full switch - price - td day and date range', async () => { + await dbRunner.runQueryTest({ + dimensions: ['source.currency', 'source.product_category'], + measures: ['source.price'], + timeDimensions: [ + { + dimension: 'source.created_at', + granularity: 'month', + dateRange: ['2022-02-01', '2022-04-01'] + } + ], + timezone: 'UTC', + order: [{ + id: 'source.created_at' + }, + { + id: 'source.product_category' + }, + { + id: 'source.currency' + } + ], + }, [ + { + source__product_category: 'some category', + source__created_at_month: '2022-02-01T00:00:00.000Z', + source__price: '500', + source__currency: 'EUR', + }, + { + source__product_category: 'some category', + source__created_at_month: '2022-02-01T00:00:00.000Z', + source__price: '0', + source__currency: 'USD', + }, + { + source__product_category: 'some category A', + source__created_at_month: '2022-02-01T00:00:00.000Z', + source__price: '0', + source__currency: 'EUR', + }, + { + source__product_category: 'some category A', + source__created_at_month: '2022-02-01T00:00:00.000Z', + source__price: '200', + source__currency: 'USD', + }, + { + source__product_category: 'some category B', + source__created_at_month: '2022-02-01T00:00:00.000Z', + source__price: '200', + source__currency: 'EUR', + }, + { + source__product_category: 'some category B', + source__created_at_month: '2022-02-01T00:00:00.000Z', + source__price: '0', + source__currency: 'USD', + }, + { + source__product_category: 'some category A', + source__created_at_month: '2022-03-01T00:00:00.000Z', + source__price: '0', + source__currency: 'EUR', + }, + { + source__product_category: 'some category A', + source__created_at_month: '2022-03-01T00:00:00.000Z', + source__price: '300', + source__currency: 'USD', + }, + { + source__product_category: 'some category B', + source__created_at_month: '2022-03-01T00:00:00.000Z', + source__price: '300', + source__currency: 'EUR', + }, + { + source__product_category: 'some category B', + source__created_at_month: '2022-03-01T00:00:00.000Z', + source__price: '0', + source__currency: 'USD', + }, + ], + { joinGraph, cubeEvaluator, compiler }); + }); + it('source full switch - price - td day and date range', async () => { + await dbRunner.runQueryTest({ + dimensions: ['source.currency', 'source.product_category'], + measures: ['source.price'], + timeDimensions: [ + { + dimension: 'source.created_at', + granularity: 'month', + dateRange: ['2022-02-01', '2022-04-01'] + } + ], + timezone: 'UTC', + order: [{ + id: 'source.created_at' + }, + { + id: 'source.product_category' + }, + { + id: 'source.currency' + } + ], + }, [ + { + source__product_category: 'some category', + source__created_at_month: '2022-02-01T00:00:00.000Z', + source__price: '500', + source__currency: 'EUR', + }, + { + source__product_category: 'some category', + source__created_at_month: '2022-02-01T00:00:00.000Z', + source__price: '0', + source__currency: 'USD', + }, + { + source__product_category: 'some category A', + source__created_at_month: '2022-02-01T00:00:00.000Z', + source__price: '0', + source__currency: 'EUR', + }, + { + source__product_category: 'some category A', + source__created_at_month: '2022-02-01T00:00:00.000Z', + source__price: '200', + source__currency: 'USD', + }, + { + source__product_category: 'some category B', + source__created_at_month: '2022-02-01T00:00:00.000Z', + source__price: '200', + source__currency: 'EUR', + }, + { + source__product_category: 'some category B', + source__created_at_month: '2022-02-01T00:00:00.000Z', + source__price: '0', + source__currency: 'USD', + }, + { + source__product_category: 'some category A', + source__created_at_month: '2022-03-01T00:00:00.000Z', + source__price: '0', + source__currency: 'EUR', + }, + { + source__product_category: 'some category A', + source__created_at_month: '2022-03-01T00:00:00.000Z', + source__price: '300', + source__currency: 'USD', + }, + { + source__product_category: 'some category B', + source__created_at_month: '2022-03-01T00:00:00.000Z', + source__price: '300', + source__currency: 'EUR', + }, + { + source__product_category: 'some category B', + source__created_at_month: '2022-03-01T00:00:00.000Z', + source__price: '0', + source__currency: 'USD', + }, + ], + { joinGraph, cubeEvaluator, compiler }); + }); + it('source switch - source_a + usd', async () => { + await dbRunner.runQueryTest({ + dimensions: ['source.currency', 'source.product_category'], + measures: ['source.price'], + order: [{ + id: 'source.product_category' + }, + ], + filters: [ + { dimension: 'source.currency', operator: 'equals', values: ['USD'] }, + { dimension: 'source.source', operator: 'equals', values: ['A'] } + ], + }, [ + { + source__currency: 'USD', + source__product_category: 'some category', + source__price: '600' + }, + { + source__currency: 'USD', + source__product_category: 'some category A', + source__price: '500' + }, + ], + { joinGraph, cubeEvaluator, compiler }); + }); + + it('source switch - source_a + usd + filter by category', async () => { + await dbRunner.runQueryTest({ + dimensions: ['source.currency', 'source.product_category'], + measures: ['source.price'], + order: [{ + id: 'source.product_category' + }, + ], + filters: [ + { dimension: 'source.currency', operator: 'equals', values: ['USD'] }, + { dimension: 'source.source', operator: 'equals', values: ['A'] }, + { dimension: 'source.product_category', operator: 'equals', values: ['some category'] }, + ], + }, [ + { + source__currency: 'USD', + source__product_category: 'some category', + source__price: '600' + }, + ], + { joinGraph, cubeEvaluator, compiler }); + }); + + it('source switch - source_b + eur', async () => { + await dbRunner.runQueryTest({ + dimensions: ['source.currency', 'source.product_category'], + measures: ['source.price'], + order: [{ + id: 'source.product_category' + }, + ], + filters: [ + { dimension: 'source.currency', operator: 'equals', values: ['EUR'] }, + { dimension: 'source.source', operator: 'equals', values: ['B'] } + ], + }, [ + { + source__currency: 'EUR', + source__product_category: 'some category', + source__price: '600' + }, + { + source__currency: 'EUR', + source__product_category: 'some category B', + source__price: '800' + }, + ], + { joinGraph, cubeEvaluator, compiler }); + }); + } else { + // This test is working only in tesseract + test.skip('calc groups tests', () => { expect(1).toBe(1); }); + } +}); diff --git a/packages/cubejs-schema-compiler/test/integration/utils/BaseDbRunner.ts b/packages/cubejs-schema-compiler/test/integration/utils/BaseDbRunner.ts index 8d7e0ee64fd42..80f3259ef4bbb 100644 --- a/packages/cubejs-schema-compiler/test/integration/utils/BaseDbRunner.ts +++ b/packages/cubejs-schema-compiler/test/integration/utils/BaseDbRunner.ts @@ -26,13 +26,15 @@ export class BaseDbRunner { const query = this.newTestQuery({ joinGraph, cubeEvaluator, compiler }, q); console.log(query.buildSqlAndParams()); + const sqlAndParams = query.buildSqlAndParams(); - const res = await this.testQuery(query.buildSqlAndParams()); + const res = await this.testQuery(sqlAndParams); console.log(JSON.stringify(res)); expect(res).toEqual( expectedResult ); + return sqlAndParams; } public async testQueries(queries, fixture: any = null) { diff --git a/packages/cubejs-schema-compiler/test/unit/sql-parser.test.ts b/packages/cubejs-schema-compiler/test/unit/sql-parser.test.ts index 74250a97e3758..654e25d75194d 100644 --- a/packages/cubejs-schema-compiler/test/unit/sql-parser.test.ts +++ b/packages/cubejs-schema-compiler/test/unit/sql-parser.test.ts @@ -126,6 +126,6 @@ describe('SqlParser', () => { // Verify table alias extraction still works after grammar changes const extractedConditions = sqlParser.extractWhereConditions('t'); - expect(extractedConditions).toEqual(`t.status = 'active' AND t.created_at > '2024-01-01'`); + expect(extractedConditions).toEqual('t.status = \'active\' AND t.created_at > \'2024-01-01\''); }); }); diff --git a/packages/cubejs-testing-drivers/fixtures/_schemas.json b/packages/cubejs-testing-drivers/fixtures/_schemas.json index 54cd412eef34d..051b644b6b322 100644 --- a/packages/cubejs-testing-drivers/fixtures/_schemas.json +++ b/packages/cubejs-testing-drivers/fixtures/_schemas.json @@ -554,5 +554,127 @@ } ] } + ], + "views": [ + { + "name": "SwitchSourceTest", + "dimensions": [ + { + "name": "source", + "type": "switch", + "values": [ + "com", + "bigCom" + ] + }, + { + "name": "curr", + "type": "switch", + "values": [ + "curr_a", + "curr_b" + ] + }, + { + "name": "orderDate", + "multiStage": true, + "type": "time", + "case": { + "switch": "{CUBE.source}", + "when": [{ + "value": "com", + "sql": "{ECommerce.orderDate}" + }, + { + "value": "bigCom", + "sql": "{BigECommerce.orderDate}" + }], + "else": { + "sql": "{BigECommerce.orderDate}" + } + } + + }, + { + "name": "city", + "multiStage": true, + "type": "string", + "case": { + "switch": "{CUBE.source}", + "when": [{ + "value": "com", + "sql": "{ECommerce.city}" + }, + { + "value": "bigCom", + "sql": "{BigECommerce.city}" + }], + "else": { + "sql": "{BigECommerce.city}" + } + } + } + ], + "measures": [ + { + "name": "totalSalesA", + "multiStage": true, + "type": "sum", + "case": { + "switch": "{CUBE.source}", + "when": [{ + "value": "com", + "sql": "{ECommerce.totalSales}" + }, + { + "value": "bigCom", + "sql": "{BigECommerce.totalSales}" + }], + "else": { + "sql": "{BigECommerce.totalSales}" + } + } + }, + { + "name": "totalSalesB", + "multiStage": true, + "type": "sum", + "case": { + "switch": "{CUBE.source}", + "when": [{ + "value": "com", + "sql": "{ECommerce.totalSales} * 2" + }, + { + "value": "bigCom", + "sql": "{BigECommerce.totalSales} * 2" + }], + "else": { + "sql": "{BigECommerce.totalSales} * 2" + } + } + }, + { + "name": "totalSales", + "multiStage": true, + "type": "sum", + "case": { + "switch": "{CUBE.curr}", + "when": [{ + "value": "curr_a", + "sql": "{CUBE.totalSalesA}" + }, + { + "value": "curr_b", + "sql": "{CUBE.totalSalesB}" + }], + "else": { + "sql": "{CUBE.totalSalesB}" + } + } + } + + ] + } ] } diff --git a/packages/cubejs-testing-drivers/fixtures/athena.json b/packages/cubejs-testing-drivers/fixtures/athena.json index 3f6bde1f96625..dc614a854111a 100644 --- a/packages/cubejs-testing-drivers/fixtures/athena.json +++ b/packages/cubejs-testing-drivers/fixtures/athena.json @@ -160,6 +160,9 @@ "Tesseract: querying BigECommerce with Retail Calendar: totalCountRetailWeekAgo", "Tesseract: SQL API: Timeshift measure from cube", "querying BigECommerce: multi-stage group by time dimension", + "querying SwitchSourceTest: simple cross join", + "querying SwitchSourceTest: full cross join", + "querying SwitchSourceTest: filter by switch dimensions", "---------------------------------------", "Custom Granularities ", diff --git a/packages/cubejs-testing-drivers/fixtures/bigquery.json b/packages/cubejs-testing-drivers/fixtures/bigquery.json index cc845e459c5db..dc582c0cecb57 100644 --- a/packages/cubejs-testing-drivers/fixtures/bigquery.json +++ b/packages/cubejs-testing-drivers/fixtures/bigquery.json @@ -174,6 +174,9 @@ "Tesseract: querying BigECommerce with Retail Calendar: totalCountRetailWeekAgo", "Tesseract: SQL API: Timeshift measure from cube", "querying BigECommerce: multi-stage group by time dimension", + "querying SwitchSourceTest: simple cross join", + "querying SwitchSourceTest: full cross join", + "querying SwitchSourceTest: filter by switch dimensions", "---------------------------------------", "SKIPPED SQL API (Need work)", diff --git a/packages/cubejs-testing-drivers/fixtures/clickhouse.json b/packages/cubejs-testing-drivers/fixtures/clickhouse.json index 48b2ca4a1ca9e..97251143c0004 100644 --- a/packages/cubejs-testing-drivers/fixtures/clickhouse.json +++ b/packages/cubejs-testing-drivers/fixtures/clickhouse.json @@ -211,6 +211,9 @@ "Tesseract: querying BigECommerce with Retail Calendar: totalCountRetailWeekAgo", "Tesseract: SQL API: Timeshift measure from cube", "querying BigECommerce: multi-stage group by time dimension", + "querying SwitchSourceTest: simple cross join", + "querying SwitchSourceTest: full cross join", + "querying SwitchSourceTest: filter by switch dimensions", "---------------------------------------", "Custom Granularities ", diff --git a/packages/cubejs-testing-drivers/fixtures/databricks-jdbc.json b/packages/cubejs-testing-drivers/fixtures/databricks-jdbc.json index 086b3fe440b03..154ed670b0035 100644 --- a/packages/cubejs-testing-drivers/fixtures/databricks-jdbc.json +++ b/packages/cubejs-testing-drivers/fixtures/databricks-jdbc.json @@ -227,6 +227,9 @@ "Tesseract: querying BigECommerce with Retail Calendar: totalCountRetailWeekAgo", "Tesseract: SQL API: Timeshift measure from cube", "querying BigECommerce: multi-stage group by time dimension", + "querying SwitchSourceTest: simple cross join", + "querying SwitchSourceTest: full cross join", + "querying SwitchSourceTest: filter by switch dimensions", "---------------------------------------", "Custom Granularities ", diff --git a/packages/cubejs-testing-drivers/fixtures/mssql.json b/packages/cubejs-testing-drivers/fixtures/mssql.json index 496c56cce9159..8e5d8505cfe88 100644 --- a/packages/cubejs-testing-drivers/fixtures/mssql.json +++ b/packages/cubejs-testing-drivers/fixtures/mssql.json @@ -153,6 +153,9 @@ "Tesseract: querying BigECommerce with Retail Calendar: totalCountRetailWeekAgo", "Tesseract: SQL API: Timeshift measure from cube", "querying BigECommerce: multi-stage group by time dimension", + "querying SwitchSourceTest: simple cross join", + "querying SwitchSourceTest: full cross join", + "querying SwitchSourceTest: filter by switch dimensions", "---------------------------------------", "SKIPPED SQL API (Need work)", diff --git a/packages/cubejs-testing-drivers/fixtures/mysql.json b/packages/cubejs-testing-drivers/fixtures/mysql.json index 4d15a568d5408..6d441b63b8f1a 100644 --- a/packages/cubejs-testing-drivers/fixtures/mysql.json +++ b/packages/cubejs-testing-drivers/fixtures/mysql.json @@ -149,6 +149,9 @@ "Tesseract: querying BigECommerce with Retail Calendar: totalCountRetailWeekAgo", "Tesseract: SQL API: Timeshift measure from cube", "querying BigECommerce: multi-stage group by time dimension", + "querying SwitchSourceTest: simple cross join", + "querying SwitchSourceTest: full cross join", + "querying SwitchSourceTest: filter by switch dimensions", "---------------------------------------", "Custom Granularities ", diff --git a/packages/cubejs-testing-drivers/fixtures/postgres.json b/packages/cubejs-testing-drivers/fixtures/postgres.json index 2a53312aa42c7..d992640a1f744 100644 --- a/packages/cubejs-testing-drivers/fixtures/postgres.json +++ b/packages/cubejs-testing-drivers/fixtures/postgres.json @@ -173,7 +173,10 @@ "Tesseract: querying BigECommerce with Retail Calendar: totalCountRetailMonthAgo", "Tesseract: querying BigECommerce with Retail Calendar: totalCountRetailWeekAgo", "Tesseract: SQL API: Timeshift measure from cube", - "querying BigECommerce: multi-stage group by time dimension" + "querying BigECommerce: multi-stage group by time dimension", + "querying SwitchSourceTest: simple cross join", + "querying SwitchSourceTest: full cross join", + "querying SwitchSourceTest: filter by switch dimensions" ], "tesseractSkip": [ "querying Products: dimensions -- doesn't work wo ordering", diff --git a/packages/cubejs-testing-drivers/fixtures/redshift.json b/packages/cubejs-testing-drivers/fixtures/redshift.json index cbae8bc7f0f08..45df73b3fed13 100644 --- a/packages/cubejs-testing-drivers/fixtures/redshift.json +++ b/packages/cubejs-testing-drivers/fixtures/redshift.json @@ -185,6 +185,9 @@ "Tesseract: querying BigECommerce with Retail Calendar: totalCountRetailWeekAgo", "Tesseract: SQL API: Timeshift measure from cube", "querying BigECommerce: multi-stage group by time dimension", + "querying SwitchSourceTest: simple cross join", + "querying SwitchSourceTest: full cross join", + "querying SwitchSourceTest: filter by switch dimensions", "---------------------------------------", "SKIPPED SQL API (Need work) ", diff --git a/packages/cubejs-testing-drivers/fixtures/snowflake.json b/packages/cubejs-testing-drivers/fixtures/snowflake.json index 6c528b7706eaf..29d46e844f592 100644 --- a/packages/cubejs-testing-drivers/fixtures/snowflake.json +++ b/packages/cubejs-testing-drivers/fixtures/snowflake.json @@ -249,7 +249,10 @@ "querying BigECommerce with Retail Calendar: totalCountRetailYearAgo", "querying BigECommerce with Retail Calendar: totalCountRetailMonthAgo", "querying BigECommerce with Retail Calendar: totalCountRetailWeekAgo", - "querying BigECommerce: multi-stage group by time dimension" + "querying BigECommerce: multi-stage group by time dimension", + "querying SwitchSourceTest: simple cross join", + "querying SwitchSourceTest: full cross join", + "querying SwitchSourceTest: filter by switch dimensions" ], "tesseractSkip": [ "for the Customers.RollingExternal", diff --git a/packages/cubejs-testing-drivers/src/tests/testQueries.ts b/packages/cubejs-testing-drivers/src/tests/testQueries.ts index 184cc9da45888..fa41cbd5d4a7f 100644 --- a/packages/cubejs-testing-drivers/src/tests/testQueries.ts +++ b/packages/cubejs-testing-drivers/src/tests/testQueries.ts @@ -2131,6 +2131,81 @@ export function testQueries(type: string, { includeIncrementalSchemaSuite, exten expect(response.rawData()).toMatchSnapshot(); }); + execute('querying SwitchSourceTest: simple cross join', async () => { + const response = await client.load({ + dimensions: [ + 'SwitchSourceTest.city' + ], + measures: [ + 'SwitchSourceTest.totalSalesA', + ], + timeDimensions: [{ + dimension: 'SwitchSourceTest.orderDate', + granularity: 'month', + dateRange: ['2020-01-01', '2020-04-01'], + }], + order: { + 'SwitchSourceTest.orderDate': 'asc', + 'SwitchSourceTest.city': 'asc' + } + }); + expect(response.rawData()).toMatchSnapshot(); + }); + + execute('querying SwitchSourceTest: full cross join', async () => { + const response = await client.load({ + dimensions: [ + 'SwitchSourceTest.city' + ], + measures: [ + 'SwitchSourceTest.totalSales', + ], + timeDimensions: [{ + dimension: 'SwitchSourceTest.orderDate', + granularity: 'month', + dateRange: ['2020-01-01', '2020-04-01'], + }], + order: { + 'SwitchSourceTest.orderDate': 'asc', + 'SwitchSourceTest.city': 'asc' + } + }); + expect(response.rawData()).toMatchSnapshot(); + }); + + execute('querying SwitchSourceTest: filter by switch dimensions', async () => { + const response = await client.load({ + dimensions: [ + 'SwitchSourceTest.city' + ], + measures: [ + 'SwitchSourceTest.totalSales', + ], + filters: [ + { + values: ['com'], + member: 'SwitchSourceTest.source', + operator: 'equals' + }, + { + values: ['curr_a'], + member: 'SwitchSourceTest.curr', + operator: 'equals' + } + ], + timeDimensions: [{ + dimension: 'SwitchSourceTest.orderDate', + granularity: 'month', + dateRange: ['2020-01-01', '2020-04-01'], + }], + order: { + 'SwitchSourceTest.orderDate': 'asc', + 'SwitchSourceTest.city': 'asc' + } + }); + expect(response.rawData()).toMatchSnapshot(); + }); + if (includeIncrementalSchemaSuite) { describe(`Incremental schema loading with @cubejs-backend/${type}-driver`, () => { incrementalSchemaLoadingSuite(execute, () => driver, tables); 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 71925c876adc2..11c827581d54d 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 @@ -30,81 +30,6 @@ Array [ ] `; -exports[`Queries with the @cubejs-backend/athena-driver querying BigECommerce: multi-stage group by time dimension 1`] = ` -Array [ - Object { - "BigECommerce.orderDate": "2020-01-01T00:00:00.000", - "BigECommerce.orderDate.month": "2020-01-01T00:00:00.000", - "BigECommerce.orderDate.quarter": "2020-01-01T00:00:00.000", - "BigECommerce.totalProfit": "29.65480", - "BigECommerce.totalProfitForQuarter": "619.44850", - }, - Object { - "BigECommerce.orderDate": "2020-02-01T00:00:00.000", - "BigECommerce.orderDate.month": "2020-02-01T00:00:00.000", - "BigECommerce.orderDate.quarter": "2020-01-01T00:00:00.000", - "BigECommerce.totalProfit": "6.19920", - "BigECommerce.totalProfitForQuarter": "619.44850", - }, - Object { - "BigECommerce.orderDate": "2020-03-01T00:00:00.000", - "BigECommerce.orderDate.month": "2020-03-01T00:00:00.000", - "BigECommerce.orderDate.quarter": "2020-01-01T00:00:00.000", - "BigECommerce.totalProfit": "583.59450", - "BigECommerce.totalProfitForQuarter": "619.44850", - }, - Object { - "BigECommerce.orderDate": "2020-04-01T00:00:00.000", - "BigECommerce.orderDate.month": "2020-04-01T00:00:00.000", - "BigECommerce.orderDate.quarter": "2020-04-01T00:00:00.000", - "BigECommerce.totalProfit": "6.41760", - "BigECommerce.totalProfitForQuarter": "394.33860", - }, - Object { - "BigECommerce.orderDate": "2020-05-01T00:00:00.000", - "BigECommerce.orderDate.month": "2020-05-01T00:00:00.000", - "BigECommerce.orderDate.quarter": "2020-04-01T00:00:00.000", - "BigECommerce.totalProfit": "353.68490", - "BigECommerce.totalProfitForQuarter": "394.33860", - }, - Object { - "BigECommerce.orderDate": "2020-06-01T00:00:00.000", - "BigECommerce.orderDate.month": "2020-06-01T00:00:00.000", - "BigECommerce.orderDate.quarter": "2020-04-01T00:00:00.000", - "BigECommerce.totalProfit": "34.23610", - "BigECommerce.totalProfitForQuarter": "394.33860", - }, - Object { - "BigECommerce.orderDate": "2020-09-01T00:00:00.000", - "BigECommerce.orderDate.month": "2020-09-01T00:00:00.000", - "BigECommerce.orderDate.quarter": "2020-07-01T00:00:00.000", - "BigECommerce.totalProfit": "461.13320", - "BigECommerce.totalProfitForQuarter": "461.13320", - }, - Object { - "BigECommerce.orderDate": "2020-10-01T00:00:00.000", - "BigECommerce.orderDate.month": "2020-10-01T00:00:00.000", - "BigECommerce.orderDate.quarter": "2020-10-01T00:00:00.000", - "BigECommerce.totalProfit": "139.99700", - "BigECommerce.totalProfitForQuarter": "1576.63240", - }, - Object { - "BigECommerce.orderDate": "2020-11-01T00:00:00.000", - "BigECommerce.orderDate.month": "2020-11-01T00:00:00.000", - "BigECommerce.orderDate.quarter": "2020-10-01T00:00:00.000", - "BigECommerce.totalProfit": "1132.66170", - "BigECommerce.totalProfitForQuarter": "1576.63240", - }, - Object { - "BigECommerce.orderDate": "2020-12-01T00:00:00.000", - "BigECommerce.orderDate.month": "2020-12-01T00:00:00.000", - "BigECommerce.orderDate.quarter": "2020-10-01T00:00:00.000", - "BigECommerce.totalProfit": "303.97370", - "BigECommerce.totalProfitForQuarter": "1576.63240", - }, -] -`; - exports[`Queries with the @cubejs-backend/athena-driver SQL API: Rolling Window YTD (year + month + day + date_trunc IN) 1`] = ` Array [ Object { @@ -849,176 +774,335 @@ Array [ ] `; -exports[`Queries with the @cubejs-backend/athena-driver filtering Customers: contains + dimensions, first 1`] = ` +exports[`Queries with the @cubejs-backend/athena-driver Tesseract: SQL API: Timeshift measure from cube 1`] = ` Array [ Object { - "Customers.customerId": "AH-10465", - "Customers.customerName": "Customer 1", + "orderDate": 2020-01-01T00:00:00.000Z, + "totalQuantity": 6, + "totalQuantityPriorMonth": null, }, Object { - "Customers.customerId": "AJ-10780", - "Customers.customerName": "Customer 2", + "orderDate": 2020-02-01T00:00:00.000Z, + "totalQuantity": 2, + "totalQuantityPriorMonth": 6, }, Object { - "Customers.customerId": "AS-10225", - "Customers.customerName": "Customer 3", + "orderDate": 2020-03-01T00:00:00.000Z, + "totalQuantity": 13, + "totalQuantityPriorMonth": 2, }, Object { - "Customers.customerId": "AW-10840", - "Customers.customerName": "Customer 4", + "orderDate": 2020-04-01T00:00:00.000Z, + "totalQuantity": 3, + "totalQuantityPriorMonth": 13, }, Object { - "Customers.customerId": "BB-11545", - "Customers.customerName": "Customer 5", + "orderDate": 2020-05-01T00:00:00.000Z, + "totalQuantity": 15, + "totalQuantityPriorMonth": 3, }, Object { - "Customers.customerId": "BF-11020", - "Customers.customerName": "Customer 6", + "orderDate": 2020-06-01T00:00:00.000Z, + "totalQuantity": 18, + "totalQuantityPriorMonth": 15, }, Object { - "Customers.customerId": "BF-11170", - "Customers.customerName": "Customer 7", + "orderDate": 2020-07-01T00:00:00.000Z, + "totalQuantity": null, + "totalQuantityPriorMonth": 18, }, Object { - "Customers.customerId": "BM-11650", - "Customers.customerName": "Customer 8", + "orderDate": 2020-09-01T00:00:00.000Z, + "totalQuantity": 27, + "totalQuantityPriorMonth": null, }, Object { - "Customers.customerId": "BS-11380", - "Customers.customerName": "Customer 9", + "orderDate": 2020-10-01T00:00:00.000Z, + "totalQuantity": 11, + "totalQuantityPriorMonth": 27, }, Object { - "Customers.customerId": "BS-11755", - "Customers.customerName": "Customer 10", + "orderDate": 2020-11-01T00:00:00.000Z, + "totalQuantity": 43, + "totalQuantityPriorMonth": 11, }, Object { - "Customers.customerId": "CA-12775", - "Customers.customerName": "Customer 11", + "orderDate": 2020-12-01T00:00:00.000Z, + "totalQuantity": 22, + "totalQuantityPriorMonth": 43, }, +] +`; + +exports[`Queries with the @cubejs-backend/athena-driver Tesseract: querying BigECommerce with Retail Calendar: totalCountRetailMonthAgo 1`] = ` +Array [ Object { - "Customers.customerId": "CC-12475", - "Customers.customerName": "Customer 12", + "BigECommerce.count": "1", + "BigECommerce.totalCountRetailMonthAgo": "1", + "RetailCalendar.retail_date": "2020-02-01T00:00:00.000", + "RetailCalendar.retail_date.month": "2020-02-01T00:00:00.000", }, Object { - "Customers.customerId": "CD-12280", - "Customers.customerName": "Customer 13", + "BigECommerce.count": "2", + "BigECommerce.totalCountRetailMonthAgo": "1", + "RetailCalendar.retail_date": "2020-03-01T00:00:00.000", + "RetailCalendar.retail_date.month": "2020-03-01T00:00:00.000", }, Object { - "Customers.customerId": "CS-12355", - "Customers.customerName": "Customer 14", + "BigECommerce.count": "1", + "BigECommerce.totalCountRetailMonthAgo": "2", + "RetailCalendar.retail_date": "2020-04-01T00:00:00.000", + "RetailCalendar.retail_date.month": "2020-04-01T00:00:00.000", }, Object { - "Customers.customerId": "DB-13405", - "Customers.customerName": "Customer 15", + "BigECommerce.count": "5", + "BigECommerce.totalCountRetailMonthAgo": "1", + "RetailCalendar.retail_date": "2020-05-01T00:00:00.000", + "RetailCalendar.retail_date.month": "2020-05-01T00:00:00.000", }, Object { - "Customers.customerId": "DG-13300", - "Customers.customerName": "Customer 16", + "BigECommerce.count": "7", + "BigECommerce.totalCountRetailMonthAgo": "5", + "RetailCalendar.retail_date": "2020-06-01T00:00:00.000", + "RetailCalendar.retail_date.month": "2020-06-01T00:00:00.000", }, Object { - "Customers.customerId": "DW-13480", - "Customers.customerName": "Customer 17", + "BigECommerce.count": null, + "BigECommerce.totalCountRetailMonthAgo": "7", + "RetailCalendar.retail_date": "2020-07-01T00:00:00.000", + "RetailCalendar.retail_date.month": "2020-07-01T00:00:00.000", }, Object { - "Customers.customerId": "EM-14140", - "Customers.customerName": "Customer 18", + "BigECommerce.count": "6", + "BigECommerce.totalCountRetailMonthAgo": null, + "RetailCalendar.retail_date": "2020-09-01T00:00:00.000", + "RetailCalendar.retail_date.month": "2020-09-01T00:00:00.000", }, Object { - "Customers.customerId": "GA-14725", - "Customers.customerName": "Customer 19", + "BigECommerce.count": "4", + "BigECommerce.totalCountRetailMonthAgo": "6", + "RetailCalendar.retail_date": "2020-10-01T00:00:00.000", + "RetailCalendar.retail_date.month": "2020-10-01T00:00:00.000", }, Object { - "Customers.customerId": "GZ-14470", - "Customers.customerName": "Customer 20", + "BigECommerce.count": "9", + "BigECommerce.totalCountRetailMonthAgo": "5", + "RetailCalendar.retail_date": "2020-11-01T00:00:00.000", + "RetailCalendar.retail_date.month": "2020-11-01T00:00:00.000", }, Object { - "Customers.customerId": "HH-15010", - "Customers.customerName": "Customer 21", + "BigECommerce.count": "7", + "BigECommerce.totalCountRetailMonthAgo": "8", + "RetailCalendar.retail_date": "2020-12-01T00:00:00.000", + "RetailCalendar.retail_date.month": "2020-12-01T00:00:00.000", }, Object { - "Customers.customerId": "HK-14890", - "Customers.customerName": "Customer 22", + "BigECommerce.count": null, + "BigECommerce.totalCountRetailMonthAgo": "7", + "RetailCalendar.retail_date": "2021-01-01T00:00:00.000", + "RetailCalendar.retail_date.month": "2021-01-01T00:00:00.000", }, +] +`; + +exports[`Queries with the @cubejs-backend/athena-driver Tesseract: querying BigECommerce with Retail Calendar: totalCountRetailWeekAgo 1`] = ` +Array [ Object { - "Customers.customerId": "JH-15430", - "Customers.customerName": "Customer 23", + "BigECommerce.count": "1", + "BigECommerce.totalCountRetailWeekAgo": null, + "RetailCalendar.retail_date": "2020-02-16T00:00:00.000", + "RetailCalendar.retail_date.week": "2020-02-16T00:00:00.000", }, Object { - "Customers.customerId": "JO-15550", - "Customers.customerName": "Customer 24", + "BigECommerce.count": null, + "BigECommerce.totalCountRetailWeekAgo": "1", + "RetailCalendar.retail_date": "2020-02-23T00:00:00.000", + "RetailCalendar.retail_date.week": "2020-02-23T00:00:00.000", }, Object { - "Customers.customerId": "JS-16030", - "Customers.customerName": "Customer 25", + "BigECommerce.count": "1", + "BigECommerce.totalCountRetailWeekAgo": null, + "RetailCalendar.retail_date": "2020-03-15T00:00:00.000", + "RetailCalendar.retail_date.week": "2020-03-15T00:00:00.000", }, Object { - "Customers.customerId": "JW-15220", - "Customers.customerName": "Customer 26", + "BigECommerce.count": "1", + "BigECommerce.totalCountRetailWeekAgo": "1", + "RetailCalendar.retail_date": "2020-03-22T00:00:00.000", + "RetailCalendar.retail_date.week": "2020-03-22T00:00:00.000", }, Object { - "Customers.customerId": "KL-16555", - "Customers.customerName": "Customer 27", + "BigECommerce.count": null, + "BigECommerce.totalCountRetailWeekAgo": "1", + "RetailCalendar.retail_date": "2020-03-29T00:00:00.000", + "RetailCalendar.retail_date.week": "2020-03-29T00:00:00.000", }, Object { - "Customers.customerId": "KN-16705", - "Customers.customerName": "Customer 28", + "BigECommerce.count": "1", + "BigECommerce.totalCountRetailWeekAgo": null, + "RetailCalendar.retail_date": "2020-04-05T00:00:00.000", + "RetailCalendar.retail_date.week": "2020-04-05T00:00:00.000", }, Object { - "Customers.customerId": "LC-17050", - "Customers.customerName": "Customer 29", + "BigECommerce.count": null, + "BigECommerce.totalCountRetailWeekAgo": "1", + "RetailCalendar.retail_date": "2020-04-12T00:00:00.000", + "RetailCalendar.retail_date.week": "2020-04-12T00:00:00.000", }, Object { - "Customers.customerId": "LR-16915", - "Customers.customerName": "Customer 30", + "BigECommerce.count": "3", + "BigECommerce.totalCountRetailWeekAgo": null, + "RetailCalendar.retail_date": "2020-05-10T00:00:00.000", + "RetailCalendar.retail_date.week": "2020-05-10T00:00:00.000", }, Object { - "Customers.customerId": "MC-17605", - "Customers.customerName": "Customer 31", + "BigECommerce.count": null, + "BigECommerce.totalCountRetailWeekAgo": "3", + "RetailCalendar.retail_date": "2020-05-17T00:00:00.000", + "RetailCalendar.retail_date.week": "2020-05-17T00:00:00.000", }, Object { - "Customers.customerId": "MG-17650", - "Customers.customerName": "Customer 32", + "BigECommerce.count": "2", + "BigECommerce.totalCountRetailWeekAgo": null, + "RetailCalendar.retail_date": "2020-05-24T00:00:00.000", + "RetailCalendar.retail_date.week": "2020-05-24T00:00:00.000", }, Object { - "Customers.customerId": "ML-17755", - "Customers.customerName": "Customer 33", + "BigECommerce.count": "1", + "BigECommerce.totalCountRetailWeekAgo": "2", + "RetailCalendar.retail_date": "2020-05-31T00:00:00.000", + "RetailCalendar.retail_date.week": "2020-05-31T00:00:00.000", }, Object { - "Customers.customerId": "MM-18280", - "Customers.customerName": "Customer 34", + "BigECommerce.count": "2", + "BigECommerce.totalCountRetailWeekAgo": "1", + "RetailCalendar.retail_date": "2020-06-07T00:00:00.000", + "RetailCalendar.retail_date.week": "2020-06-07T00:00:00.000", }, Object { - "Customers.customerId": "NP-18670", - "Customers.customerName": "Customer 35", + "BigECommerce.count": "2", + "BigECommerce.totalCountRetailWeekAgo": "2", + "RetailCalendar.retail_date": "2020-06-14T00:00:00.000", + "RetailCalendar.retail_date.week": "2020-06-14T00:00:00.000", }, Object { - "Customers.customerId": "PF-19165", - "Customers.customerName": "Customer 36", + "BigECommerce.count": "2", + "BigECommerce.totalCountRetailWeekAgo": "2", + "RetailCalendar.retail_date": "2020-06-21T00:00:00.000", + "RetailCalendar.retail_date.week": "2020-06-21T00:00:00.000", }, Object { - "Customers.customerId": "SB-20185", - "Customers.customerName": "Customer 37", + "BigECommerce.count": null, + "BigECommerce.totalCountRetailWeekAgo": "2", + "RetailCalendar.retail_date": "2020-06-28T00:00:00.000", + "RetailCalendar.retail_date.week": "2020-06-28T00:00:00.000", }, Object { - "Customers.customerId": "SS-20140", - "Customers.customerName": "Customer 38", + "BigECommerce.count": "2", + "BigECommerce.totalCountRetailWeekAgo": null, + "RetailCalendar.retail_date": "2020-08-30T00:00:00.000", + "RetailCalendar.retail_date.week": "2020-08-30T00:00:00.000", }, Object { - "Customers.customerId": "TB-21175", - "Customers.customerName": "Customer 39", + "BigECommerce.count": "1", + "BigECommerce.totalCountRetailWeekAgo": "2", + "RetailCalendar.retail_date": "2020-09-06T00:00:00.000", + "RetailCalendar.retail_date.week": "2020-09-06T00:00:00.000", }, Object { - "Customers.customerId": "TS-21205", - "Customers.customerName": "Customer 40", + "BigECommerce.count": "2", + "BigECommerce.totalCountRetailWeekAgo": "1", + "RetailCalendar.retail_date": "2020-09-13T00:00:00.000", + "RetailCalendar.retail_date.week": "2020-09-13T00:00:00.000", }, Object { - "Customers.customerId": "WB-21850", - "Customers.customerName": "Customer 41", + "BigECommerce.count": "1", + "BigECommerce.totalCountRetailWeekAgo": "2", + "RetailCalendar.retail_date": "2020-09-20T00:00:00.000", + "RetailCalendar.retail_date.week": "2020-09-20T00:00:00.000", + }, + Object { + "BigECommerce.count": null, + "BigECommerce.totalCountRetailWeekAgo": "1", + "RetailCalendar.retail_date": "2020-09-27T00:00:00.000", + "RetailCalendar.retail_date.week": "2020-09-27T00:00:00.000", + }, + Object { + "BigECommerce.count": "1", + "BigECommerce.totalCountRetailWeekAgo": null, + "RetailCalendar.retail_date": "2020-10-11T00:00:00.000", + "RetailCalendar.retail_date.week": "2020-10-11T00:00:00.000", + }, + Object { + "BigECommerce.count": "2", + "BigECommerce.totalCountRetailWeekAgo": "1", + "RetailCalendar.retail_date": "2020-10-18T00:00:00.000", + "RetailCalendar.retail_date.week": "2020-10-18T00:00:00.000", + }, + Object { + "BigECommerce.count": "1", + "BigECommerce.totalCountRetailWeekAgo": "2", + "RetailCalendar.retail_date": "2020-10-25T00:00:00.000", + "RetailCalendar.retail_date.week": "2020-10-25T00:00:00.000", + }, + Object { + "BigECommerce.count": "3", + "BigECommerce.totalCountRetailWeekAgo": "1", + "RetailCalendar.retail_date": "2020-11-01T00:00:00.000", + "RetailCalendar.retail_date.week": "2020-11-01T00:00:00.000", + }, + Object { + "BigECommerce.count": "2", + "BigECommerce.totalCountRetailWeekAgo": "3", + "RetailCalendar.retail_date": "2020-11-08T00:00:00.000", + "RetailCalendar.retail_date.week": "2020-11-08T00:00:00.000", + }, + Object { + "BigECommerce.count": "3", + "BigECommerce.totalCountRetailWeekAgo": "2", + "RetailCalendar.retail_date": "2020-11-15T00:00:00.000", + "RetailCalendar.retail_date.week": "2020-11-15T00:00:00.000", + }, + Object { + "BigECommerce.count": "1", + "BigECommerce.totalCountRetailWeekAgo": "3", + "RetailCalendar.retail_date": "2020-11-22T00:00:00.000", + "RetailCalendar.retail_date.week": "2020-11-22T00:00:00.000", + }, + Object { + "BigECommerce.count": "3", + "BigECommerce.totalCountRetailWeekAgo": "1", + "RetailCalendar.retail_date": "2020-11-29T00:00:00.000", + "RetailCalendar.retail_date.week": "2020-11-29T00:00:00.000", + }, + Object { + "BigECommerce.count": null, + "BigECommerce.totalCountRetailWeekAgo": "3", + "RetailCalendar.retail_date": "2020-12-06T00:00:00.000", + "RetailCalendar.retail_date.week": "2020-12-06T00:00:00.000", + }, + Object { + "BigECommerce.count": "2", + "BigECommerce.totalCountRetailWeekAgo": null, + "RetailCalendar.retail_date": "2020-12-13T00:00:00.000", + "RetailCalendar.retail_date.week": "2020-12-13T00:00:00.000", + }, + Object { + "BigECommerce.count": "2", + "BigECommerce.totalCountRetailWeekAgo": "2", + "RetailCalendar.retail_date": "2020-12-20T00:00:00.000", + "RetailCalendar.retail_date.week": "2020-12-20T00:00:00.000", + }, + Object { + "BigECommerce.count": null, + "BigECommerce.totalCountRetailWeekAgo": "2", + "RetailCalendar.retail_date": "2020-12-27T00:00:00.000", + "RetailCalendar.retail_date.week": "2020-12-27T00:00:00.000", }, ] `; -exports[`Queries with the @cubejs-backend/athena-driver filtering Customers: contains + dimensions, second 1`] = ` +exports[`Queries with the @cubejs-backend/athena-driver filtering Customers: contains + dimensions, first 1`] = ` Array [ Object { "Customers.customerId": "AH-10465", @@ -1187,106 +1271,7 @@ Array [ ] `; -exports[`Queries with the @cubejs-backend/athena-driver filtering Customers: contains + dimensions, third 1`] = `Array []`; - -exports[`Queries with the @cubejs-backend/athena-driver filtering Customers: endsWith filter + dimensions, first 1`] = ` -Array [ - Object { - "Customers.customerId": "AJ-10780", - "Customers.customerName": "Customer 2", - }, - Object { - "Customers.customerId": "AW-10840", - "Customers.customerName": "Customer 4", - }, - Object { - "Customers.customerId": "BF-11020", - "Customers.customerName": "Customer 6", - }, - Object { - "Customers.customerId": "BF-11170", - "Customers.customerName": "Customer 7", - }, - Object { - "Customers.customerId": "BM-11650", - "Customers.customerName": "Customer 8", - }, - Object { - "Customers.customerId": "BS-11380", - "Customers.customerName": "Customer 9", - }, - Object { - "Customers.customerId": "CD-12280", - "Customers.customerName": "Customer 13", - }, - Object { - "Customers.customerId": "DG-13300", - "Customers.customerName": "Customer 16", - }, - Object { - "Customers.customerId": "DW-13480", - "Customers.customerName": "Customer 17", - }, - Object { - "Customers.customerId": "EM-14140", - "Customers.customerName": "Customer 18", - }, - Object { - "Customers.customerId": "GZ-14470", - "Customers.customerName": "Customer 20", - }, - Object { - "Customers.customerId": "HH-15010", - "Customers.customerName": "Customer 21", - }, - Object { - "Customers.customerId": "HK-14890", - "Customers.customerName": "Customer 22", - }, - Object { - "Customers.customerId": "JH-15430", - "Customers.customerName": "Customer 23", - }, - Object { - "Customers.customerId": "JO-15550", - "Customers.customerName": "Customer 24", - }, - Object { - "Customers.customerId": "JS-16030", - "Customers.customerName": "Customer 25", - }, - Object { - "Customers.customerId": "JW-15220", - "Customers.customerName": "Customer 26", - }, - Object { - "Customers.customerId": "LC-17050", - "Customers.customerName": "Customer 29", - }, - Object { - "Customers.customerId": "MG-17650", - "Customers.customerName": "Customer 32", - }, - Object { - "Customers.customerId": "MM-18280", - "Customers.customerName": "Customer 34", - }, - Object { - "Customers.customerId": "NP-18670", - "Customers.customerName": "Customer 35", - }, - Object { - "Customers.customerId": "SS-20140", - "Customers.customerName": "Customer 38", - }, - Object { - "Customers.customerId": "WB-21850", - "Customers.customerName": "Customer 41", - }, -] -`; - -exports[`Queries with the @cubejs-backend/athena-driver filtering Customers: endsWith filter + dimensions, second 1`] = ` +exports[`Queries with the @cubejs-backend/athena-driver filtering Customers: contains + dimensions, second 1`] = ` Array [ Object { "Customers.customerId": "AH-10465", @@ -1455,88 +1440,106 @@ Array [ ] `; -exports[`Queries with the @cubejs-backend/athena-driver filtering Customers: endsWith filter + dimensions, third 1`] = `Array []`; +exports[`Queries with the @cubejs-backend/athena-driver filtering Customers: contains + dimensions, third 1`] = `Array []`; -exports[`Queries with the @cubejs-backend/athena-driver filtering Customers: notEndsWith filter + dimensions, first 1`] = ` +exports[`Queries with the @cubejs-backend/athena-driver filtering Customers: endsWith filter + dimensions, first 1`] = ` Array [ Object { - "Customers.customerId": "AH-10465", - "Customers.customerName": "Customer 1", + "Customers.customerId": "AJ-10780", + "Customers.customerName": "Customer 2", }, Object { - "Customers.customerId": "AS-10225", - "Customers.customerName": "Customer 3", + "Customers.customerId": "AW-10840", + "Customers.customerName": "Customer 4", }, Object { - "Customers.customerId": "BB-11545", - "Customers.customerName": "Customer 5", + "Customers.customerId": "BF-11020", + "Customers.customerName": "Customer 6", }, Object { - "Customers.customerId": "BS-11755", - "Customers.customerName": "Customer 10", + "Customers.customerId": "BF-11170", + "Customers.customerName": "Customer 7", }, Object { - "Customers.customerId": "CA-12775", - "Customers.customerName": "Customer 11", + "Customers.customerId": "BM-11650", + "Customers.customerName": "Customer 8", }, Object { - "Customers.customerId": "CC-12475", - "Customers.customerName": "Customer 12", + "Customers.customerId": "BS-11380", + "Customers.customerName": "Customer 9", }, Object { - "Customers.customerId": "CS-12355", - "Customers.customerName": "Customer 14", + "Customers.customerId": "CD-12280", + "Customers.customerName": "Customer 13", }, Object { - "Customers.customerId": "DB-13405", - "Customers.customerName": "Customer 15", + "Customers.customerId": "DG-13300", + "Customers.customerName": "Customer 16", }, Object { - "Customers.customerId": "GA-14725", - "Customers.customerName": "Customer 19", + "Customers.customerId": "DW-13480", + "Customers.customerName": "Customer 17", }, Object { - "Customers.customerId": "KL-16555", - "Customers.customerName": "Customer 27", + "Customers.customerId": "EM-14140", + "Customers.customerName": "Customer 18", }, Object { - "Customers.customerId": "KN-16705", - "Customers.customerName": "Customer 28", + "Customers.customerId": "GZ-14470", + "Customers.customerName": "Customer 20", }, Object { - "Customers.customerId": "LR-16915", - "Customers.customerName": "Customer 30", + "Customers.customerId": "HH-15010", + "Customers.customerName": "Customer 21", }, Object { - "Customers.customerId": "MC-17605", - "Customers.customerName": "Customer 31", + "Customers.customerId": "HK-14890", + "Customers.customerName": "Customer 22", }, Object { - "Customers.customerId": "ML-17755", - "Customers.customerName": "Customer 33", + "Customers.customerId": "JH-15430", + "Customers.customerName": "Customer 23", }, Object { - "Customers.customerId": "PF-19165", - "Customers.customerName": "Customer 36", + "Customers.customerId": "JO-15550", + "Customers.customerName": "Customer 24", }, Object { - "Customers.customerId": "SB-20185", - "Customers.customerName": "Customer 37", + "Customers.customerId": "JS-16030", + "Customers.customerName": "Customer 25", }, Object { - "Customers.customerId": "TB-21175", - "Customers.customerName": "Customer 39", + "Customers.customerId": "JW-15220", + "Customers.customerName": "Customer 26", }, Object { - "Customers.customerId": "TS-21205", - "Customers.customerName": "Customer 40", + "Customers.customerId": "LC-17050", + "Customers.customerName": "Customer 29", + }, + Object { + "Customers.customerId": "MG-17650", + "Customers.customerName": "Customer 32", + }, + Object { + "Customers.customerId": "MM-18280", + "Customers.customerName": "Customer 34", + }, + Object { + "Customers.customerId": "NP-18670", + "Customers.customerName": "Customer 35", + }, + Object { + "Customers.customerId": "SS-20140", + "Customers.customerName": "Customer 38", + }, + Object { + "Customers.customerId": "WB-21850", + "Customers.customerName": "Customer 41", }, ] `; -exports[`Queries with the @cubejs-backend/athena-driver filtering Customers: notEndsWith filter + dimensions, second 1`] = `Array []`; - -exports[`Queries with the @cubejs-backend/athena-driver filtering Customers: notEndsWith filter + dimensions, third 1`] = ` +exports[`Queries with the @cubejs-backend/athena-driver filtering Customers: endsWith filter + dimensions, second 1`] = ` Array [ Object { "Customers.customerId": "AH-10465", @@ -1705,27 +1708,21 @@ Array [ ] `; -exports[`Queries with the @cubejs-backend/athena-driver filtering Customers: notStartsWith + dimensions, first 1`] = ` +exports[`Queries with the @cubejs-backend/athena-driver filtering Customers: endsWith filter + dimensions, third 1`] = `Array []`; + +exports[`Queries with the @cubejs-backend/athena-driver filtering Customers: notEndsWith filter + dimensions, first 1`] = ` Array [ Object { - "Customers.customerId": "BB-11545", - "Customers.customerName": "Customer 5", - }, - Object { - "Customers.customerId": "BF-11020", - "Customers.customerName": "Customer 6", - }, - Object { - "Customers.customerId": "BF-11170", - "Customers.customerName": "Customer 7", + "Customers.customerId": "AH-10465", + "Customers.customerName": "Customer 1", }, Object { - "Customers.customerId": "BM-11650", - "Customers.customerName": "Customer 8", + "Customers.customerId": "AS-10225", + "Customers.customerName": "Customer 3", }, Object { - "Customers.customerId": "BS-11380", - "Customers.customerName": "Customer 9", + "Customers.customerId": "BB-11545", + "Customers.customerName": "Customer 5", }, Object { "Customers.customerId": "BS-11755", @@ -1739,10 +1736,6 @@ Array [ "Customers.customerId": "CC-12475", "Customers.customerName": "Customer 12", }, - Object { - "Customers.customerId": "CD-12280", - "Customers.customerName": "Customer 13", - }, Object { "Customers.customerId": "CS-12355", "Customers.customerName": "Customer 14", @@ -1751,50 +1744,10 @@ Array [ "Customers.customerId": "DB-13405", "Customers.customerName": "Customer 15", }, - Object { - "Customers.customerId": "DG-13300", - "Customers.customerName": "Customer 16", - }, - Object { - "Customers.customerId": "DW-13480", - "Customers.customerName": "Customer 17", - }, - Object { - "Customers.customerId": "EM-14140", - "Customers.customerName": "Customer 18", - }, Object { "Customers.customerId": "GA-14725", "Customers.customerName": "Customer 19", }, - Object { - "Customers.customerId": "GZ-14470", - "Customers.customerName": "Customer 20", - }, - Object { - "Customers.customerId": "HH-15010", - "Customers.customerName": "Customer 21", - }, - Object { - "Customers.customerId": "HK-14890", - "Customers.customerName": "Customer 22", - }, - Object { - "Customers.customerId": "JH-15430", - "Customers.customerName": "Customer 23", - }, - Object { - "Customers.customerId": "JO-15550", - "Customers.customerName": "Customer 24", - }, - Object { - "Customers.customerId": "JS-16030", - "Customers.customerName": "Customer 25", - }, - Object { - "Customers.customerId": "JW-15220", - "Customers.customerName": "Customer 26", - }, Object { "Customers.customerId": "KL-16555", "Customers.customerName": "Customer 27", @@ -1803,10 +1756,6 @@ Array [ "Customers.customerId": "KN-16705", "Customers.customerName": "Customer 28", }, - Object { - "Customers.customerId": "LC-17050", - "Customers.customerName": "Customer 29", - }, Object { "Customers.customerId": "LR-16915", "Customers.customerName": "Customer 30", @@ -1815,22 +1764,10 @@ Array [ "Customers.customerId": "MC-17605", "Customers.customerName": "Customer 31", }, - Object { - "Customers.customerId": "MG-17650", - "Customers.customerName": "Customer 32", - }, Object { "Customers.customerId": "ML-17755", "Customers.customerName": "Customer 33", }, - Object { - "Customers.customerId": "MM-18280", - "Customers.customerName": "Customer 34", - }, - Object { - "Customers.customerId": "NP-18670", - "Customers.customerName": "Customer 35", - }, Object { "Customers.customerId": "PF-19165", "Customers.customerName": "Customer 36", @@ -1839,10 +1776,6 @@ Array [ "Customers.customerId": "SB-20185", "Customers.customerName": "Customer 37", }, - Object { - "Customers.customerId": "SS-20140", - "Customers.customerName": "Customer 38", - }, Object { "Customers.customerId": "TB-21175", "Customers.customerName": "Customer 39", @@ -1851,15 +1784,53 @@ Array [ "Customers.customerId": "TS-21205", "Customers.customerName": "Customer 40", }, - Object { - "Customers.customerId": "WB-21850", - "Customers.customerName": "Customer 41", - }, ] `; -exports[`Queries with the @cubejs-backend/athena-driver filtering Customers: notStartsWith + dimensions, second 1`] = ` +exports[`Queries with the @cubejs-backend/athena-driver filtering Customers: notEndsWith filter + dimensions, second 1`] = `Array []`; + +exports[`Queries with the @cubejs-backend/athena-driver filtering Customers: notEndsWith filter + dimensions, third 1`] = ` Array [ + Object { + "Customers.customerId": "AH-10465", + "Customers.customerName": "Customer 1", + }, + Object { + "Customers.customerId": "AJ-10780", + "Customers.customerName": "Customer 2", + }, + Object { + "Customers.customerId": "AS-10225", + "Customers.customerName": "Customer 3", + }, + Object { + "Customers.customerId": "AW-10840", + "Customers.customerName": "Customer 4", + }, + Object { + "Customers.customerId": "BB-11545", + "Customers.customerName": "Customer 5", + }, + Object { + "Customers.customerId": "BF-11020", + "Customers.customerName": "Customer 6", + }, + Object { + "Customers.customerId": "BF-11170", + "Customers.customerName": "Customer 7", + }, + Object { + "Customers.customerId": "BM-11650", + "Customers.customerName": "Customer 8", + }, + Object { + "Customers.customerId": "BS-11380", + "Customers.customerName": "Customer 9", + }, + Object { + "Customers.customerId": "BS-11755", + "Customers.customerName": "Customer 10", + }, Object { "Customers.customerId": "CA-12775", "Customers.customerName": "Customer 11", @@ -1987,24 +1958,8 @@ Array [ ] `; -exports[`Queries with the @cubejs-backend/athena-driver filtering Customers: notStartsWith + dimensions, third 1`] = ` +exports[`Queries with the @cubejs-backend/athena-driver filtering Customers: notStartsWith + dimensions, first 1`] = ` Array [ - Object { - "Customers.customerId": "AH-10465", - "Customers.customerName": "Customer 1", - }, - Object { - "Customers.customerId": "AJ-10780", - "Customers.customerName": "Customer 2", - }, - Object { - "Customers.customerId": "AS-10225", - "Customers.customerName": "Customer 3", - }, - Object { - "Customers.customerId": "AW-10840", - "Customers.customerName": "Customer 4", - }, Object { "Customers.customerId": "BB-11545", "Customers.customerName": "Customer 5", @@ -2156,28 +2111,136 @@ Array [ ] `; -exports[`Queries with the @cubejs-backend/athena-driver filtering Customers: startsWith + dimensions, first 1`] = ` +exports[`Queries with the @cubejs-backend/athena-driver filtering Customers: notStartsWith + dimensions, second 1`] = ` Array [ Object { - "Customers.customerId": "AH-10465", - "Customers.customerName": "Customer 1", + "Customers.customerId": "CA-12775", + "Customers.customerName": "Customer 11", }, Object { - "Customers.customerId": "AJ-10780", - "Customers.customerName": "Customer 2", + "Customers.customerId": "CC-12475", + "Customers.customerName": "Customer 12", }, Object { - "Customers.customerId": "AS-10225", - "Customers.customerName": "Customer 3", + "Customers.customerId": "CD-12280", + "Customers.customerName": "Customer 13", }, Object { - "Customers.customerId": "AW-10840", - "Customers.customerName": "Customer 4", + "Customers.customerId": "CS-12355", + "Customers.customerName": "Customer 14", + }, + Object { + "Customers.customerId": "DB-13405", + "Customers.customerName": "Customer 15", + }, + Object { + "Customers.customerId": "DG-13300", + "Customers.customerName": "Customer 16", + }, + Object { + "Customers.customerId": "DW-13480", + "Customers.customerName": "Customer 17", + }, + Object { + "Customers.customerId": "EM-14140", + "Customers.customerName": "Customer 18", + }, + Object { + "Customers.customerId": "GA-14725", + "Customers.customerName": "Customer 19", + }, + Object { + "Customers.customerId": "GZ-14470", + "Customers.customerName": "Customer 20", + }, + Object { + "Customers.customerId": "HH-15010", + "Customers.customerName": "Customer 21", + }, + Object { + "Customers.customerId": "HK-14890", + "Customers.customerName": "Customer 22", + }, + Object { + "Customers.customerId": "JH-15430", + "Customers.customerName": "Customer 23", + }, + Object { + "Customers.customerId": "JO-15550", + "Customers.customerName": "Customer 24", + }, + Object { + "Customers.customerId": "JS-16030", + "Customers.customerName": "Customer 25", + }, + Object { + "Customers.customerId": "JW-15220", + "Customers.customerName": "Customer 26", + }, + Object { + "Customers.customerId": "KL-16555", + "Customers.customerName": "Customer 27", + }, + Object { + "Customers.customerId": "KN-16705", + "Customers.customerName": "Customer 28", + }, + Object { + "Customers.customerId": "LC-17050", + "Customers.customerName": "Customer 29", + }, + Object { + "Customers.customerId": "LR-16915", + "Customers.customerName": "Customer 30", + }, + Object { + "Customers.customerId": "MC-17605", + "Customers.customerName": "Customer 31", + }, + Object { + "Customers.customerId": "MG-17650", + "Customers.customerName": "Customer 32", + }, + Object { + "Customers.customerId": "ML-17755", + "Customers.customerName": "Customer 33", + }, + Object { + "Customers.customerId": "MM-18280", + "Customers.customerName": "Customer 34", + }, + Object { + "Customers.customerId": "NP-18670", + "Customers.customerName": "Customer 35", + }, + Object { + "Customers.customerId": "PF-19165", + "Customers.customerName": "Customer 36", + }, + Object { + "Customers.customerId": "SB-20185", + "Customers.customerName": "Customer 37", + }, + Object { + "Customers.customerId": "SS-20140", + "Customers.customerName": "Customer 38", + }, + Object { + "Customers.customerId": "TB-21175", + "Customers.customerName": "Customer 39", + }, + Object { + "Customers.customerId": "TS-21205", + "Customers.customerName": "Customer 40", + }, + Object { + "Customers.customerId": "WB-21850", + "Customers.customerName": "Customer 41", }, ] `; -exports[`Queries with the @cubejs-backend/athena-driver filtering Customers: startsWith + dimensions, second 1`] = ` +exports[`Queries with the @cubejs-backend/athena-driver filtering Customers: notStartsWith + dimensions, third 1`] = ` Array [ Object { "Customers.customerId": "AH-10465", @@ -2219,209 +2282,237 @@ Array [ "Customers.customerId": "BS-11755", "Customers.customerName": "Customer 10", }, -] -`; - -exports[`Queries with the @cubejs-backend/athena-driver filtering Customers: startsWith + dimensions, third 1`] = `Array []`; - -exports[`Queries with the @cubejs-backend/athena-driver filtering ECommerce: contains dimensions, first 1`] = ` -Array [ Object { - "ECommerce.category": "Furniture", - "ECommerce.city": "Detroit", - "ECommerce.customerId": "MC-17605", - "ECommerce.customerName": "Customer 31", - "ECommerce.discount": "0.0", - "ECommerce.orderDate": "2020-01-23T00:00:00.000", - "ECommerce.orderId": "CA-2017-145142", - "ECommerce.productName": "Balt Solid Wood Rectangular Table", - "ECommerce.profit": "21.098", - "ECommerce.quantity": "2", - "ECommerce.rowId": "523", - "ECommerce.sales": "210.98", - "ECommerce.subCategory": "Tables", + "Customers.customerId": "CA-12775", + "Customers.customerName": "Customer 11", }, Object { - "ECommerce.category": "Furniture", - "ECommerce.city": "San Francisco", - "ECommerce.customerId": "HH-15010", - "ECommerce.customerName": "Customer 21", - "ECommerce.discount": "0.2", - "ECommerce.orderDate": "2020-10-19T00:00:00.000", - "ECommerce.orderId": "CA-2017-131492", - "ECommerce.productName": "Anderson Hickey Conga Table Tops & Accessories", - "ECommerce.profit": "-3.3506", - "ECommerce.quantity": "2", - "ECommerce.rowId": "3060", - "ECommerce.sales": "24.368", - "ECommerce.subCategory": "Tables", + "Customers.customerId": "CC-12475", + "Customers.customerName": "Customer 12", }, -] -`; - -exports[`Queries with the @cubejs-backend/athena-driver filtering ECommerce: contains dimensions, second 1`] = ` -Array [ Object { - "ECommerce.category": "Furniture", - "ECommerce.city": "Detroit", - "ECommerce.customerId": "MC-17605", - "ECommerce.customerName": "Customer 31", - "ECommerce.discount": "0.0", - "ECommerce.orderDate": "2020-01-23T00:00:00.000", - "ECommerce.orderId": "CA-2017-145142", - "ECommerce.productName": "Balt Solid Wood Rectangular Table", - "ECommerce.profit": "21.098", - "ECommerce.quantity": "2", - "ECommerce.rowId": "523", - "ECommerce.sales": "210.98", - "ECommerce.subCategory": "Tables", + "Customers.customerId": "CD-12280", + "Customers.customerName": "Customer 13", }, Object { - "ECommerce.category": "Furniture", - "ECommerce.city": "Lorain", - "ECommerce.customerId": "GA-14725", - "ECommerce.customerName": "Customer 19", - "ECommerce.discount": "0.2", - "ECommerce.orderDate": "2020-01-01T00:00:00.000", - "ECommerce.orderId": "CA-2017-107503", - "ECommerce.productName": "Linden 10 Round Wall Clock, Black", - "ECommerce.profit": "8.5568", - "ECommerce.quantity": "4", - "ECommerce.rowId": "849", - "ECommerce.sales": "48.896", - "ECommerce.subCategory": "Furnishings", + "Customers.customerId": "CS-12355", + "Customers.customerName": "Customer 14", }, Object { - "ECommerce.category": "Furniture", - "ECommerce.city": "Vancouver", - "ECommerce.customerId": "JW-15220", - "ECommerce.customerName": "Customer 26", - "ECommerce.discount": "0.0", - "ECommerce.orderDate": "2020-10-30T00:00:00.000", - "ECommerce.orderId": "CA-2017-139661", - "ECommerce.productName": "Magna Visual Magnetic Picture Hangers", - "ECommerce.profit": "3.6632", - "ECommerce.quantity": "2", - "ECommerce.rowId": "1494", - "ECommerce.sales": "9.64", - "ECommerce.subCategory": "Furnishings", + "Customers.customerId": "DB-13405", + "Customers.customerName": "Customer 15", }, Object { - "ECommerce.category": "Furniture", - "ECommerce.city": "San Francisco", - "ECommerce.customerId": "HH-15010", - "ECommerce.customerName": "Customer 21", - "ECommerce.discount": "0.0", - "ECommerce.orderDate": "2020-10-19T00:00:00.000", - "ECommerce.orderId": "CA-2017-131492", - "ECommerce.productName": "Linden 10 Round Wall Clock, Black", - "ECommerce.profit": "10.3904", - "ECommerce.quantity": "2", - "ECommerce.rowId": "3059", - "ECommerce.sales": "30.56", - "ECommerce.subCategory": "Furnishings", + "Customers.customerId": "DG-13300", + "Customers.customerName": "Customer 16", }, Object { - "ECommerce.category": "Furniture", - "ECommerce.city": "San Francisco", - "ECommerce.customerId": "HH-15010", - "ECommerce.customerName": "Customer 21", - "ECommerce.discount": "0.2", - "ECommerce.orderDate": "2020-10-19T00:00:00.000", - "ECommerce.orderId": "CA-2017-131492", - "ECommerce.productName": "Anderson Hickey Conga Table Tops & Accessories", - "ECommerce.profit": "-3.3506", - "ECommerce.quantity": "2", - "ECommerce.rowId": "3060", - "ECommerce.sales": "24.368", - "ECommerce.subCategory": "Tables", + "Customers.customerId": "DW-13480", + "Customers.customerName": "Customer 17", }, Object { - "ECommerce.category": "Furniture", - "ECommerce.city": "Marion", - "ECommerce.customerId": "MG-17650", - "ECommerce.customerName": "Customer 32", - "ECommerce.discount": "0.2", - "ECommerce.orderDate": "2020-12-01T00:00:00.000", - "ECommerce.orderId": "CA-2017-145660", - "ECommerce.productName": "Magna Visual Magnetic Picture Hangers", - "ECommerce.profit": "1.7352", - "ECommerce.quantity": "2", - "ECommerce.rowId": "6205", - "ECommerce.sales": "7.712", - "ECommerce.subCategory": "Furnishings", + "Customers.customerId": "EM-14140", + "Customers.customerName": "Customer 18", }, Object { - "ECommerce.category": "Furniture", - "ECommerce.city": "Philadelphia", - "ECommerce.customerId": "BS-11755", - "ECommerce.customerName": "Customer 10", - "ECommerce.discount": "0.2", - "ECommerce.orderDate": "2020-04-10T00:00:00.000", - "ECommerce.orderId": "CA-2017-135069", - "ECommerce.productName": "Linden 10 Round Wall Clock, Black", - "ECommerce.profit": "6.4176", - "ECommerce.quantity": "3", - "ECommerce.rowId": "7425", - "ECommerce.sales": "36.672", - "ECommerce.subCategory": "Furnishings", + "Customers.customerId": "GA-14725", + "Customers.customerName": "Customer 19", }, Object { - "ECommerce.category": "Furniture", - "ECommerce.city": "Dallas", - "ECommerce.customerId": "LC-17050", - "ECommerce.customerName": "Customer 29", - "ECommerce.discount": "0.6", - "ECommerce.orderDate": "2020-11-06T00:00:00.000", - "ECommerce.orderId": "US-2017-119319", - "ECommerce.productName": "Linden 10 Round Wall Clock, Black", - "ECommerce.profit": "-19.864", - "ECommerce.quantity": "5", - "ECommerce.rowId": "8621", - "ECommerce.sales": "30.56", - "ECommerce.subCategory": "Furnishings", + "Customers.customerId": "GZ-14470", + "Customers.customerName": "Customer 20", + }, + Object { + "Customers.customerId": "HH-15010", + "Customers.customerName": "Customer 21", + }, + Object { + "Customers.customerId": "HK-14890", + "Customers.customerName": "Customer 22", + }, + Object { + "Customers.customerId": "JH-15430", + "Customers.customerName": "Customer 23", + }, + Object { + "Customers.customerId": "JO-15550", + "Customers.customerName": "Customer 24", + }, + Object { + "Customers.customerId": "JS-16030", + "Customers.customerName": "Customer 25", + }, + Object { + "Customers.customerId": "JW-15220", + "Customers.customerName": "Customer 26", + }, + Object { + "Customers.customerId": "KL-16555", + "Customers.customerName": "Customer 27", + }, + Object { + "Customers.customerId": "KN-16705", + "Customers.customerName": "Customer 28", + }, + Object { + "Customers.customerId": "LC-17050", + "Customers.customerName": "Customer 29", + }, + Object { + "Customers.customerId": "LR-16915", + "Customers.customerName": "Customer 30", + }, + Object { + "Customers.customerId": "MC-17605", + "Customers.customerName": "Customer 31", + }, + Object { + "Customers.customerId": "MG-17650", + "Customers.customerName": "Customer 32", + }, + Object { + "Customers.customerId": "ML-17755", + "Customers.customerName": "Customer 33", + }, + Object { + "Customers.customerId": "MM-18280", + "Customers.customerName": "Customer 34", + }, + Object { + "Customers.customerId": "NP-18670", + "Customers.customerName": "Customer 35", + }, + Object { + "Customers.customerId": "PF-19165", + "Customers.customerName": "Customer 36", + }, + Object { + "Customers.customerId": "SB-20185", + "Customers.customerName": "Customer 37", + }, + Object { + "Customers.customerId": "SS-20140", + "Customers.customerName": "Customer 38", + }, + Object { + "Customers.customerId": "TB-21175", + "Customers.customerName": "Customer 39", + }, + Object { + "Customers.customerId": "TS-21205", + "Customers.customerName": "Customer 40", + }, + Object { + "Customers.customerId": "WB-21850", + "Customers.customerName": "Customer 41", }, ] `; -exports[`Queries with the @cubejs-backend/athena-driver filtering ECommerce: contains dimensions, third 1`] = `Array []`; +exports[`Queries with the @cubejs-backend/athena-driver filtering Customers: startsWith + dimensions, first 1`] = ` +Array [ + Object { + "Customers.customerId": "AH-10465", + "Customers.customerName": "Customer 1", + }, + Object { + "Customers.customerId": "AJ-10780", + "Customers.customerName": "Customer 2", + }, + Object { + "Customers.customerId": "AS-10225", + "Customers.customerName": "Customer 3", + }, + Object { + "Customers.customerId": "AW-10840", + "Customers.customerName": "Customer 4", + }, +] +`; -exports[`Queries with the @cubejs-backend/athena-driver filtering ECommerce: endsWith + dimensions, first 1`] = ` +exports[`Queries with the @cubejs-backend/athena-driver filtering Customers: startsWith + dimensions, second 1`] = ` +Array [ + Object { + "Customers.customerId": "AH-10465", + "Customers.customerName": "Customer 1", + }, + Object { + "Customers.customerId": "AJ-10780", + "Customers.customerName": "Customer 2", + }, + Object { + "Customers.customerId": "AS-10225", + "Customers.customerName": "Customer 3", + }, + Object { + "Customers.customerId": "AW-10840", + "Customers.customerName": "Customer 4", + }, + Object { + "Customers.customerId": "BB-11545", + "Customers.customerName": "Customer 5", + }, + Object { + "Customers.customerId": "BF-11020", + "Customers.customerName": "Customer 6", + }, + Object { + "Customers.customerId": "BF-11170", + "Customers.customerName": "Customer 7", + }, + Object { + "Customers.customerId": "BM-11650", + "Customers.customerName": "Customer 8", + }, + Object { + "Customers.customerId": "BS-11380", + "Customers.customerName": "Customer 9", + }, + Object { + "Customers.customerId": "BS-11755", + "Customers.customerName": "Customer 10", + }, +] +`; + +exports[`Queries with the @cubejs-backend/athena-driver filtering Customers: startsWith + dimensions, third 1`] = `Array []`; + +exports[`Queries with the @cubejs-backend/athena-driver filtering ECommerce: contains dimensions, first 1`] = ` Array [ Object { "ECommerce.category": "Furniture", - "ECommerce.city": "Marion", - "ECommerce.customerId": "MG-17650", - "ECommerce.customerName": "Customer 32", - "ECommerce.discount": "0.2", - "ECommerce.orderDate": "2020-12-01T00:00:00.000", - "ECommerce.orderId": "CA-2017-145660", - "ECommerce.productName": "Magna Visual Magnetic Picture Hangers", - "ECommerce.profit": "1.7352", + "ECommerce.city": "Detroit", + "ECommerce.customerId": "MC-17605", + "ECommerce.customerName": "Customer 31", + "ECommerce.discount": "0.0", + "ECommerce.orderDate": "2020-01-23T00:00:00.000", + "ECommerce.orderId": "CA-2017-145142", + "ECommerce.productName": "Balt Solid Wood Rectangular Table", + "ECommerce.profit": "21.098", "ECommerce.quantity": "2", - "ECommerce.rowId": "6205", - "ECommerce.sales": "7.712", - "ECommerce.subCategory": "Furnishings", + "ECommerce.rowId": "523", + "ECommerce.sales": "210.98", + "ECommerce.subCategory": "Tables", }, Object { - "ECommerce.category": "Technology", - "ECommerce.city": "Columbus", - "ECommerce.customerId": "JH-15430", - "ECommerce.customerName": "Customer 23", - "ECommerce.discount": "0.5", - "ECommerce.orderDate": "2020-12-25T00:00:00.000", - "ECommerce.orderId": "CA-2017-105620", - "ECommerce.productName": "Lexmark 20R1285 X6650 Wireless All-in-One Printer", - "ECommerce.profit": "-7.2", + "ECommerce.category": "Furniture", + "ECommerce.city": "San Francisco", + "ECommerce.customerId": "HH-15010", + "ECommerce.customerName": "Customer 21", + "ECommerce.discount": "0.2", + "ECommerce.orderDate": "2020-10-19T00:00:00.000", + "ECommerce.orderId": "CA-2017-131492", + "ECommerce.productName": "Anderson Hickey Conga Table Tops & Accessories", + "ECommerce.profit": "-3.3506", "ECommerce.quantity": "2", - "ECommerce.rowId": "8958", - "ECommerce.sales": "120.0", - "ECommerce.subCategory": "Machines", + "ECommerce.rowId": "3060", + "ECommerce.sales": "24.368", + "ECommerce.subCategory": "Tables", }, ] `; -exports[`Queries with the @cubejs-backend/athena-driver filtering ECommerce: endsWith + dimensions, second 1`] = ` +exports[`Queries with the @cubejs-backend/athena-driver filtering ECommerce: contains dimensions, second 1`] = ` Array [ Object { "ECommerce.category": "Furniture", @@ -2438,6 +2529,21 @@ Array [ "ECommerce.sales": "210.98", "ECommerce.subCategory": "Tables", }, + Object { + "ECommerce.category": "Furniture", + "ECommerce.city": "Lorain", + "ECommerce.customerId": "GA-14725", + "ECommerce.customerName": "Customer 19", + "ECommerce.discount": "0.2", + "ECommerce.orderDate": "2020-01-01T00:00:00.000", + "ECommerce.orderId": "CA-2017-107503", + "ECommerce.productName": "Linden 10 Round Wall Clock, Black", + "ECommerce.profit": "8.5568", + "ECommerce.quantity": "4", + "ECommerce.rowId": "849", + "ECommerce.sales": "48.896", + "ECommerce.subCategory": "Furnishings", + }, Object { "ECommerce.category": "Furniture", "ECommerce.city": "Vancouver", @@ -2454,22 +2560,169 @@ Array [ "ECommerce.subCategory": "Furnishings", }, Object { - "ECommerce.category": "Office Supplies", - "ECommerce.city": "Columbus", - "ECommerce.customerId": "KN-16705", - "ECommerce.customerName": "Customer 28", - "ECommerce.discount": "0.2", - "ECommerce.orderDate": "2020-09-23T00:00:00.000", - "ECommerce.orderId": "CA-2017-138422", - "ECommerce.productName": "Wausau Papers Astrobrights Colored Envelopes", - "ECommerce.profit": "5.2026", - "ECommerce.quantity": "3", - "ECommerce.rowId": "2329", - "ECommerce.sales": "14.352", - "ECommerce.subCategory": "Envelopes", - }, - Object { - "ECommerce.category": "Technology", + "ECommerce.category": "Furniture", + "ECommerce.city": "San Francisco", + "ECommerce.customerId": "HH-15010", + "ECommerce.customerName": "Customer 21", + "ECommerce.discount": "0.0", + "ECommerce.orderDate": "2020-10-19T00:00:00.000", + "ECommerce.orderId": "CA-2017-131492", + "ECommerce.productName": "Linden 10 Round Wall Clock, Black", + "ECommerce.profit": "10.3904", + "ECommerce.quantity": "2", + "ECommerce.rowId": "3059", + "ECommerce.sales": "30.56", + "ECommerce.subCategory": "Furnishings", + }, + Object { + "ECommerce.category": "Furniture", + "ECommerce.city": "San Francisco", + "ECommerce.customerId": "HH-15010", + "ECommerce.customerName": "Customer 21", + "ECommerce.discount": "0.2", + "ECommerce.orderDate": "2020-10-19T00:00:00.000", + "ECommerce.orderId": "CA-2017-131492", + "ECommerce.productName": "Anderson Hickey Conga Table Tops & Accessories", + "ECommerce.profit": "-3.3506", + "ECommerce.quantity": "2", + "ECommerce.rowId": "3060", + "ECommerce.sales": "24.368", + "ECommerce.subCategory": "Tables", + }, + Object { + "ECommerce.category": "Furniture", + "ECommerce.city": "Marion", + "ECommerce.customerId": "MG-17650", + "ECommerce.customerName": "Customer 32", + "ECommerce.discount": "0.2", + "ECommerce.orderDate": "2020-12-01T00:00:00.000", + "ECommerce.orderId": "CA-2017-145660", + "ECommerce.productName": "Magna Visual Magnetic Picture Hangers", + "ECommerce.profit": "1.7352", + "ECommerce.quantity": "2", + "ECommerce.rowId": "6205", + "ECommerce.sales": "7.712", + "ECommerce.subCategory": "Furnishings", + }, + Object { + "ECommerce.category": "Furniture", + "ECommerce.city": "Philadelphia", + "ECommerce.customerId": "BS-11755", + "ECommerce.customerName": "Customer 10", + "ECommerce.discount": "0.2", + "ECommerce.orderDate": "2020-04-10T00:00:00.000", + "ECommerce.orderId": "CA-2017-135069", + "ECommerce.productName": "Linden 10 Round Wall Clock, Black", + "ECommerce.profit": "6.4176", + "ECommerce.quantity": "3", + "ECommerce.rowId": "7425", + "ECommerce.sales": "36.672", + "ECommerce.subCategory": "Furnishings", + }, + Object { + "ECommerce.category": "Furniture", + "ECommerce.city": "Dallas", + "ECommerce.customerId": "LC-17050", + "ECommerce.customerName": "Customer 29", + "ECommerce.discount": "0.6", + "ECommerce.orderDate": "2020-11-06T00:00:00.000", + "ECommerce.orderId": "US-2017-119319", + "ECommerce.productName": "Linden 10 Round Wall Clock, Black", + "ECommerce.profit": "-19.864", + "ECommerce.quantity": "5", + "ECommerce.rowId": "8621", + "ECommerce.sales": "30.56", + "ECommerce.subCategory": "Furnishings", + }, +] +`; + +exports[`Queries with the @cubejs-backend/athena-driver filtering ECommerce: contains dimensions, third 1`] = `Array []`; + +exports[`Queries with the @cubejs-backend/athena-driver filtering ECommerce: endsWith + dimensions, first 1`] = ` +Array [ + Object { + "ECommerce.category": "Furniture", + "ECommerce.city": "Marion", + "ECommerce.customerId": "MG-17650", + "ECommerce.customerName": "Customer 32", + "ECommerce.discount": "0.2", + "ECommerce.orderDate": "2020-12-01T00:00:00.000", + "ECommerce.orderId": "CA-2017-145660", + "ECommerce.productName": "Magna Visual Magnetic Picture Hangers", + "ECommerce.profit": "1.7352", + "ECommerce.quantity": "2", + "ECommerce.rowId": "6205", + "ECommerce.sales": "7.712", + "ECommerce.subCategory": "Furnishings", + }, + Object { + "ECommerce.category": "Technology", + "ECommerce.city": "Columbus", + "ECommerce.customerId": "JH-15430", + "ECommerce.customerName": "Customer 23", + "ECommerce.discount": "0.5", + "ECommerce.orderDate": "2020-12-25T00:00:00.000", + "ECommerce.orderId": "CA-2017-105620", + "ECommerce.productName": "Lexmark 20R1285 X6650 Wireless All-in-One Printer", + "ECommerce.profit": "-7.2", + "ECommerce.quantity": "2", + "ECommerce.rowId": "8958", + "ECommerce.sales": "120.0", + "ECommerce.subCategory": "Machines", + }, +] +`; + +exports[`Queries with the @cubejs-backend/athena-driver filtering ECommerce: endsWith + dimensions, second 1`] = ` +Array [ + Object { + "ECommerce.category": "Furniture", + "ECommerce.city": "Detroit", + "ECommerce.customerId": "MC-17605", + "ECommerce.customerName": "Customer 31", + "ECommerce.discount": "0.0", + "ECommerce.orderDate": "2020-01-23T00:00:00.000", + "ECommerce.orderId": "CA-2017-145142", + "ECommerce.productName": "Balt Solid Wood Rectangular Table", + "ECommerce.profit": "21.098", + "ECommerce.quantity": "2", + "ECommerce.rowId": "523", + "ECommerce.sales": "210.98", + "ECommerce.subCategory": "Tables", + }, + Object { + "ECommerce.category": "Furniture", + "ECommerce.city": "Vancouver", + "ECommerce.customerId": "JW-15220", + "ECommerce.customerName": "Customer 26", + "ECommerce.discount": "0.0", + "ECommerce.orderDate": "2020-10-30T00:00:00.000", + "ECommerce.orderId": "CA-2017-139661", + "ECommerce.productName": "Magna Visual Magnetic Picture Hangers", + "ECommerce.profit": "3.6632", + "ECommerce.quantity": "2", + "ECommerce.rowId": "1494", + "ECommerce.sales": "9.64", + "ECommerce.subCategory": "Furnishings", + }, + Object { + "ECommerce.category": "Office Supplies", + "ECommerce.city": "Columbus", + "ECommerce.customerId": "KN-16705", + "ECommerce.customerName": "Customer 28", + "ECommerce.discount": "0.2", + "ECommerce.orderDate": "2020-09-23T00:00:00.000", + "ECommerce.orderId": "CA-2017-138422", + "ECommerce.productName": "Wausau Papers Astrobrights Colored Envelopes", + "ECommerce.profit": "5.2026", + "ECommerce.quantity": "3", + "ECommerce.rowId": "2329", + "ECommerce.sales": "14.352", + "ECommerce.subCategory": "Envelopes", + }, + Object { + "ECommerce.category": "Technology", "ECommerce.city": "Columbus", "ECommerce.customerId": "DG-13300", "ECommerce.customerName": "Customer 16", @@ -2826,636 +3079,308 @@ Array [ "ECommerce.subCategory": "Copiers", }, Object { - "ECommerce.category": "Office Supplies", - "ECommerce.city": "Bowling", - "ECommerce.customerId": "BS-11380", - "ECommerce.customerName": "Customer 9", - "ECommerce.discount": "0.2", - "ECommerce.orderDate": "2020-11-16T00:00:00.000", - "ECommerce.orderId": "CA-2017-160633", - "ECommerce.productName": "Panasonic KP-380BK Classic Electric Pencil Sharpener", - "ECommerce.profit": "5.397", - "ECommerce.quantity": "3", - "ECommerce.rowId": "9619", - "ECommerce.sales": "86.352", - "ECommerce.subCategory": "Art", - }, -] -`; - -exports[`Queries with the @cubejs-backend/athena-driver filtering ECommerce: startsWith + dimensions, third 1`] = `Array []`; - -exports[`Queries with the @cubejs-backend/athena-driver filtering Products: contains + dimensions + order, first 1`] = ` -Array [ - Object { - "Products.category": "Furniture", - "Products.productName": "Anderson Hickey Conga Table Tops & Accessories", - "Products.subCategory": "Tables", - }, - Object { - "Products.category": "Furniture", - "Products.productName": "Balt Solid Wood Rectangular Table", - "Products.subCategory": "Tables", - }, -] -`; - -exports[`Queries with the @cubejs-backend/athena-driver filtering Products: contains + dimensions + order, second 1`] = ` -Array [ - Object { - "Products.category": "Furniture", - "Products.productName": "Linden 10 Round Wall Clock, Black", - "Products.subCategory": "Furnishings", - }, - Object { - "Products.category": "Furniture", - "Products.productName": "Magna Visual Magnetic Picture Hangers", - "Products.subCategory": "Furnishings", - }, - Object { - "Products.category": "Furniture", - "Products.productName": "Anderson Hickey Conga Table Tops & Accessories", - "Products.subCategory": "Tables", - }, - Object { - "Products.category": "Furniture", - "Products.productName": "Balt Solid Wood Rectangular Table", - "Products.subCategory": "Tables", - }, -] -`; - -exports[`Queries with the @cubejs-backend/athena-driver filtering Products: contains + dimensions + order, third 1`] = `Array []`; - -exports[`Queries with the @cubejs-backend/athena-driver filtering Products: contains with special chars + dimensions 1`] = ` -Array [ - Object { - "Products.productName": "Logitech di_Novo Edge Keyboard", - }, -] -`; - -exports[`Queries with the @cubejs-backend/athena-driver filtering Products: endsWith filter + dimensions + order, first 1`] = ` -Array [ - Object { - "Products.category": "Furniture", - "Products.productName": "DMI Eclipse Executive Suite Bookcases", - "Products.subCategory": "Bookcases", - }, - Object { - "Products.category": "Furniture", - "Products.productName": "Global Adaptabilites Bookcase, Cherry/Storm Gray Finish", - "Products.subCategory": "Bookcases", - }, - Object { - "Products.category": "Furniture", - "Products.productName": "Anderson Hickey Conga Table Tops & Accessories", - "Products.subCategory": "Tables", - }, - Object { - "Products.category": "Furniture", - "Products.productName": "Balt Solid Wood Rectangular Table", - "Products.subCategory": "Tables", - }, - Object { - "Products.category": "Office Supplies", - "Products.productName": "Tyvek Side-Opening Peel & Seel Expanding Envelopes", - "Products.subCategory": "Envelopes", - }, - Object { - "Products.category": "Office Supplies", - "Products.productName": "Wausau Papers Astrobrights Colored Envelopes", - "Products.subCategory": "Envelopes", - }, - Object { - "Products.category": "Technology", - "Products.productName": "Kingston Digital DataTraveler 16GB USB 2.0", - "Products.subCategory": "Accessories", - }, - Object { - "Products.category": "Technology", - "Products.productName": "Kingston Digital DataTraveler 16GB USB 2.1", - "Products.subCategory": "Accessories", - }, - Object { - "Products.category": "Technology", - "Products.productName": "Kingston Digital DataTraveler 16GB USB 2.2", - "Products.subCategory": "Accessories", - }, - Object { - "Products.category": "Technology", - "Products.productName": "Logitech di_Novo Edge Keyboard", - "Products.subCategory": "Accessories", - }, - Object { - "Products.category": "Technology", - "Products.productName": "Lexmark 20R1285 X6650 Wireless All-in-One Printer", - "Products.subCategory": "Machines", - }, - Object { - "Products.category": "Technology", - "Products.productName": "Okidata C610n Printer", - "Products.subCategory": "Machines", - }, - Object { - "Products.category": "Technology", - "Products.productName": "Google Nexus 5", - "Products.subCategory": "Phones", - }, - Object { - "Products.category": "Technology", - "Products.productName": "Google Nexus 6", - "Products.subCategory": "Phones", - }, - Object { - "Products.category": "Technology", - "Products.productName": "Google Nexus 7", - "Products.subCategory": "Phones", - }, - Object { - "Products.category": "Technology", - "Products.productName": "HTC One", - "Products.subCategory": "Phones", - }, -] -`; - -exports[`Queries with the @cubejs-backend/athena-driver filtering Products: endsWith filter + dimensions + order, second 1`] = ` -Array [ - Object { - "Products.category": "Furniture", - "Products.productName": "DMI Eclipse Executive Suite Bookcases", - "Products.subCategory": "Bookcases", - }, - Object { - "Products.category": "Furniture", - "Products.productName": "Global Adaptabilites Bookcase, Cherry/Storm Gray Finish", - "Products.subCategory": "Bookcases", - }, - Object { - "Products.category": "Furniture", - "Products.productName": "Linden 10 Round Wall Clock, Black", - "Products.subCategory": "Furnishings", - }, - Object { - "Products.category": "Furniture", - "Products.productName": "Magna Visual Magnetic Picture Hangers", - "Products.subCategory": "Furnishings", - }, - Object { - "Products.category": "Furniture", - "Products.productName": "Anderson Hickey Conga Table Tops & Accessories", - "Products.subCategory": "Tables", - }, - Object { - "Products.category": "Furniture", - "Products.productName": "Balt Solid Wood Rectangular Table", - "Products.subCategory": "Tables", - }, - Object { - "Products.category": "Office Supplies", - "Products.productName": "Tyvek Side-Opening Peel & Seel Expanding Envelopes", - "Products.subCategory": "Envelopes", - }, - Object { - "Products.category": "Office Supplies", - "Products.productName": "Wausau Papers Astrobrights Colored Envelopes", - "Products.subCategory": "Envelopes", - }, - Object { - "Products.category": "Technology", - "Products.productName": "Kingston Digital DataTraveler 16GB USB 2.0", - "Products.subCategory": "Accessories", - }, - Object { - "Products.category": "Technology", - "Products.productName": "Kingston Digital DataTraveler 16GB USB 2.1", - "Products.subCategory": "Accessories", - }, - Object { - "Products.category": "Technology", - "Products.productName": "Kingston Digital DataTraveler 16GB USB 2.2", - "Products.subCategory": "Accessories", - }, - Object { - "Products.category": "Technology", - "Products.productName": "Logitech di_Novo Edge Keyboard", - "Products.subCategory": "Accessories", - }, - Object { - "Products.category": "Technology", - "Products.productName": "Lexmark 20R1285 X6650 Wireless All-in-One Printer", - "Products.subCategory": "Machines", - }, - Object { - "Products.category": "Technology", - "Products.productName": "Okidata C610n Printer", - "Products.subCategory": "Machines", - }, - Object { - "Products.category": "Technology", - "Products.productName": "Google Nexus 5", - "Products.subCategory": "Phones", - }, - Object { - "Products.category": "Technology", - "Products.productName": "Google Nexus 6", - "Products.subCategory": "Phones", - }, - Object { - "Products.category": "Technology", - "Products.productName": "Google Nexus 7", - "Products.subCategory": "Phones", - }, - Object { - "Products.category": "Technology", - "Products.productName": "HTC One", - "Products.subCategory": "Phones", - }, -] -`; - -exports[`Queries with the @cubejs-backend/athena-driver filtering Products: endsWith filter + dimensions + order, third 1`] = `Array []`; - -exports[`Queries with the @cubejs-backend/athena-driver filtering Products: startsWith filter + dimensions + order, first 1`] = ` -Array [ - Object { - "Products.category": "Office Supplies", - "Products.productName": "OIC #2 Pencils, Medium Soft", - "Products.subCategory": "Art", - }, - Object { - "Products.category": "Technology", - "Products.productName": "Okidata C610n Printer", - "Products.subCategory": "Machines", - }, -] -`; - -exports[`Queries with the @cubejs-backend/athena-driver filtering Products: startsWith filter + dimensions + order, second 1`] = ` -Array [ - Object { - "Products.category": "Office Supplies", - "Products.productName": "OIC #2 Pencils, Medium Soft", - "Products.subCategory": "Art", - }, - Object { - "Products.category": "Technology", - "Products.productName": "Kingston Digital DataTraveler 16GB USB 2.0", - "Products.subCategory": "Accessories", - }, - Object { - "Products.category": "Technology", - "Products.productName": "Kingston Digital DataTraveler 16GB USB 2.1", - "Products.subCategory": "Accessories", - }, - Object { - "Products.category": "Technology", - "Products.productName": "Kingston Digital DataTraveler 16GB USB 2.2", - "Products.subCategory": "Accessories", - }, - Object { - "Products.category": "Technology", - "Products.productName": "Okidata C610n Printer", - "Products.subCategory": "Machines", - }, -] -`; - -exports[`Queries with the @cubejs-backend/athena-driver filtering Products: startsWith filter + dimensions + order, third 1`] = `Array []`; - -exports[`Queries with the @cubejs-backend/athena-driver pre-aggregations Customers: running total without time dimension 1`] = ` -Array [ - Object { - "Customers.runningTotal": "41", - }, -] -`; - -exports[`Queries with the @cubejs-backend/athena-driver Tesseract: querying BigECommerce with Retail Calendar: totalCountRetailMonthAgo 1`] = ` -Array [ - Object { - "BigECommerce.count": "1", - "BigECommerce.totalCountRetailMonthAgo": "1", - "RetailCalendar.retail_date": "2020-02-01T00:00:00.000", - "RetailCalendar.retail_date.month": "2020-02-01T00:00:00.000", - }, - Object { - "BigECommerce.count": "2", - "BigECommerce.totalCountRetailMonthAgo": "1", - "RetailCalendar.retail_date": "2020-03-01T00:00:00.000", - "RetailCalendar.retail_date.month": "2020-03-01T00:00:00.000", - }, - Object { - "BigECommerce.count": "1", - "BigECommerce.totalCountRetailMonthAgo": "2", - "RetailCalendar.retail_date": "2020-04-01T00:00:00.000", - "RetailCalendar.retail_date.month": "2020-04-01T00:00:00.000", - }, - Object { - "BigECommerce.count": "5", - "BigECommerce.totalCountRetailMonthAgo": "1", - "RetailCalendar.retail_date": "2020-05-01T00:00:00.000", - "RetailCalendar.retail_date.month": "2020-05-01T00:00:00.000", - }, - Object { - "BigECommerce.count": "7", - "BigECommerce.totalCountRetailMonthAgo": "5", - "RetailCalendar.retail_date": "2020-06-01T00:00:00.000", - "RetailCalendar.retail_date.month": "2020-06-01T00:00:00.000", + "ECommerce.category": "Office Supplies", + "ECommerce.city": "Bowling", + "ECommerce.customerId": "BS-11380", + "ECommerce.customerName": "Customer 9", + "ECommerce.discount": "0.2", + "ECommerce.orderDate": "2020-11-16T00:00:00.000", + "ECommerce.orderId": "CA-2017-160633", + "ECommerce.productName": "Panasonic KP-380BK Classic Electric Pencil Sharpener", + "ECommerce.profit": "5.397", + "ECommerce.quantity": "3", + "ECommerce.rowId": "9619", + "ECommerce.sales": "86.352", + "ECommerce.subCategory": "Art", }, +] +`; + +exports[`Queries with the @cubejs-backend/athena-driver filtering ECommerce: startsWith + dimensions, third 1`] = `Array []`; + +exports[`Queries with the @cubejs-backend/athena-driver filtering Products: contains + dimensions + order, first 1`] = ` +Array [ Object { - "BigECommerce.count": null, - "BigECommerce.totalCountRetailMonthAgo": "7", - "RetailCalendar.retail_date": "2020-07-01T00:00:00.000", - "RetailCalendar.retail_date.month": "2020-07-01T00:00:00.000", + "Products.category": "Furniture", + "Products.productName": "Anderson Hickey Conga Table Tops & Accessories", + "Products.subCategory": "Tables", }, Object { - "BigECommerce.count": "6", - "BigECommerce.totalCountRetailMonthAgo": null, - "RetailCalendar.retail_date": "2020-09-01T00:00:00.000", - "RetailCalendar.retail_date.month": "2020-09-01T00:00:00.000", + "Products.category": "Furniture", + "Products.productName": "Balt Solid Wood Rectangular Table", + "Products.subCategory": "Tables", }, +] +`; + +exports[`Queries with the @cubejs-backend/athena-driver filtering Products: contains + dimensions + order, second 1`] = ` +Array [ Object { - "BigECommerce.count": "4", - "BigECommerce.totalCountRetailMonthAgo": "6", - "RetailCalendar.retail_date": "2020-10-01T00:00:00.000", - "RetailCalendar.retail_date.month": "2020-10-01T00:00:00.000", + "Products.category": "Furniture", + "Products.productName": "Linden 10 Round Wall Clock, Black", + "Products.subCategory": "Furnishings", }, Object { - "BigECommerce.count": "9", - "BigECommerce.totalCountRetailMonthAgo": "5", - "RetailCalendar.retail_date": "2020-11-01T00:00:00.000", - "RetailCalendar.retail_date.month": "2020-11-01T00:00:00.000", + "Products.category": "Furniture", + "Products.productName": "Magna Visual Magnetic Picture Hangers", + "Products.subCategory": "Furnishings", }, Object { - "BigECommerce.count": "7", - "BigECommerce.totalCountRetailMonthAgo": "8", - "RetailCalendar.retail_date": "2020-12-01T00:00:00.000", - "RetailCalendar.retail_date.month": "2020-12-01T00:00:00.000", + "Products.category": "Furniture", + "Products.productName": "Anderson Hickey Conga Table Tops & Accessories", + "Products.subCategory": "Tables", }, Object { - "BigECommerce.count": null, - "BigECommerce.totalCountRetailMonthAgo": "7", - "RetailCalendar.retail_date": "2021-01-01T00:00:00.000", - "RetailCalendar.retail_date.month": "2021-01-01T00:00:00.000", + "Products.category": "Furniture", + "Products.productName": "Balt Solid Wood Rectangular Table", + "Products.subCategory": "Tables", }, ] `; -exports[`Queries with the @cubejs-backend/athena-driver Tesseract: querying BigECommerce with Retail Calendar: totalCountRetailWeekAgo 1`] = ` +exports[`Queries with the @cubejs-backend/athena-driver filtering Products: contains + dimensions + order, third 1`] = `Array []`; + +exports[`Queries with the @cubejs-backend/athena-driver filtering Products: contains with special chars + dimensions 1`] = ` Array [ Object { - "BigECommerce.count": "1", - "BigECommerce.totalCountRetailWeekAgo": null, - "RetailCalendar.retail_date": "2020-02-16T00:00:00.000", - "RetailCalendar.retail_date.week": "2020-02-16T00:00:00.000", + "Products.productName": "Logitech di_Novo Edge Keyboard", }, +] +`; + +exports[`Queries with the @cubejs-backend/athena-driver filtering Products: endsWith filter + dimensions + order, first 1`] = ` +Array [ Object { - "BigECommerce.count": null, - "BigECommerce.totalCountRetailWeekAgo": "1", - "RetailCalendar.retail_date": "2020-02-23T00:00:00.000", - "RetailCalendar.retail_date.week": "2020-02-23T00:00:00.000", + "Products.category": "Furniture", + "Products.productName": "DMI Eclipse Executive Suite Bookcases", + "Products.subCategory": "Bookcases", }, Object { - "BigECommerce.count": "1", - "BigECommerce.totalCountRetailWeekAgo": null, - "RetailCalendar.retail_date": "2020-03-15T00:00:00.000", - "RetailCalendar.retail_date.week": "2020-03-15T00:00:00.000", + "Products.category": "Furniture", + "Products.productName": "Global Adaptabilites Bookcase, Cherry/Storm Gray Finish", + "Products.subCategory": "Bookcases", }, Object { - "BigECommerce.count": "1", - "BigECommerce.totalCountRetailWeekAgo": "1", - "RetailCalendar.retail_date": "2020-03-22T00:00:00.000", - "RetailCalendar.retail_date.week": "2020-03-22T00:00:00.000", + "Products.category": "Furniture", + "Products.productName": "Anderson Hickey Conga Table Tops & Accessories", + "Products.subCategory": "Tables", }, Object { - "BigECommerce.count": null, - "BigECommerce.totalCountRetailWeekAgo": "1", - "RetailCalendar.retail_date": "2020-03-29T00:00:00.000", - "RetailCalendar.retail_date.week": "2020-03-29T00:00:00.000", + "Products.category": "Furniture", + "Products.productName": "Balt Solid Wood Rectangular Table", + "Products.subCategory": "Tables", }, Object { - "BigECommerce.count": "1", - "BigECommerce.totalCountRetailWeekAgo": null, - "RetailCalendar.retail_date": "2020-04-05T00:00:00.000", - "RetailCalendar.retail_date.week": "2020-04-05T00:00:00.000", + "Products.category": "Office Supplies", + "Products.productName": "Tyvek Side-Opening Peel & Seel Expanding Envelopes", + "Products.subCategory": "Envelopes", }, Object { - "BigECommerce.count": null, - "BigECommerce.totalCountRetailWeekAgo": "1", - "RetailCalendar.retail_date": "2020-04-12T00:00:00.000", - "RetailCalendar.retail_date.week": "2020-04-12T00:00:00.000", + "Products.category": "Office Supplies", + "Products.productName": "Wausau Papers Astrobrights Colored Envelopes", + "Products.subCategory": "Envelopes", }, Object { - "BigECommerce.count": "3", - "BigECommerce.totalCountRetailWeekAgo": null, - "RetailCalendar.retail_date": "2020-05-10T00:00:00.000", - "RetailCalendar.retail_date.week": "2020-05-10T00:00:00.000", + "Products.category": "Technology", + "Products.productName": "Kingston Digital DataTraveler 16GB USB 2.0", + "Products.subCategory": "Accessories", }, Object { - "BigECommerce.count": null, - "BigECommerce.totalCountRetailWeekAgo": "3", - "RetailCalendar.retail_date": "2020-05-17T00:00:00.000", - "RetailCalendar.retail_date.week": "2020-05-17T00:00:00.000", + "Products.category": "Technology", + "Products.productName": "Kingston Digital DataTraveler 16GB USB 2.1", + "Products.subCategory": "Accessories", }, Object { - "BigECommerce.count": "2", - "BigECommerce.totalCountRetailWeekAgo": null, - "RetailCalendar.retail_date": "2020-05-24T00:00:00.000", - "RetailCalendar.retail_date.week": "2020-05-24T00:00:00.000", + "Products.category": "Technology", + "Products.productName": "Kingston Digital DataTraveler 16GB USB 2.2", + "Products.subCategory": "Accessories", }, Object { - "BigECommerce.count": "1", - "BigECommerce.totalCountRetailWeekAgo": "2", - "RetailCalendar.retail_date": "2020-05-31T00:00:00.000", - "RetailCalendar.retail_date.week": "2020-05-31T00:00:00.000", + "Products.category": "Technology", + "Products.productName": "Logitech di_Novo Edge Keyboard", + "Products.subCategory": "Accessories", }, Object { - "BigECommerce.count": "2", - "BigECommerce.totalCountRetailWeekAgo": "1", - "RetailCalendar.retail_date": "2020-06-07T00:00:00.000", - "RetailCalendar.retail_date.week": "2020-06-07T00:00:00.000", + "Products.category": "Technology", + "Products.productName": "Lexmark 20R1285 X6650 Wireless All-in-One Printer", + "Products.subCategory": "Machines", }, Object { - "BigECommerce.count": "2", - "BigECommerce.totalCountRetailWeekAgo": "2", - "RetailCalendar.retail_date": "2020-06-14T00:00:00.000", - "RetailCalendar.retail_date.week": "2020-06-14T00:00:00.000", + "Products.category": "Technology", + "Products.productName": "Okidata C610n Printer", + "Products.subCategory": "Machines", }, Object { - "BigECommerce.count": "2", - "BigECommerce.totalCountRetailWeekAgo": "2", - "RetailCalendar.retail_date": "2020-06-21T00:00:00.000", - "RetailCalendar.retail_date.week": "2020-06-21T00:00:00.000", + "Products.category": "Technology", + "Products.productName": "Google Nexus 5", + "Products.subCategory": "Phones", }, Object { - "BigECommerce.count": null, - "BigECommerce.totalCountRetailWeekAgo": "2", - "RetailCalendar.retail_date": "2020-06-28T00:00:00.000", - "RetailCalendar.retail_date.week": "2020-06-28T00:00:00.000", + "Products.category": "Technology", + "Products.productName": "Google Nexus 6", + "Products.subCategory": "Phones", }, Object { - "BigECommerce.count": "2", - "BigECommerce.totalCountRetailWeekAgo": null, - "RetailCalendar.retail_date": "2020-08-30T00:00:00.000", - "RetailCalendar.retail_date.week": "2020-08-30T00:00:00.000", + "Products.category": "Technology", + "Products.productName": "Google Nexus 7", + "Products.subCategory": "Phones", }, Object { - "BigECommerce.count": "1", - "BigECommerce.totalCountRetailWeekAgo": "2", - "RetailCalendar.retail_date": "2020-09-06T00:00:00.000", - "RetailCalendar.retail_date.week": "2020-09-06T00:00:00.000", + "Products.category": "Technology", + "Products.productName": "HTC One", + "Products.subCategory": "Phones", }, +] +`; + +exports[`Queries with the @cubejs-backend/athena-driver filtering Products: endsWith filter + dimensions + order, second 1`] = ` +Array [ Object { - "BigECommerce.count": "2", - "BigECommerce.totalCountRetailWeekAgo": "1", - "RetailCalendar.retail_date": "2020-09-13T00:00:00.000", - "RetailCalendar.retail_date.week": "2020-09-13T00:00:00.000", + "Products.category": "Furniture", + "Products.productName": "DMI Eclipse Executive Suite Bookcases", + "Products.subCategory": "Bookcases", }, Object { - "BigECommerce.count": "1", - "BigECommerce.totalCountRetailWeekAgo": "2", - "RetailCalendar.retail_date": "2020-09-20T00:00:00.000", - "RetailCalendar.retail_date.week": "2020-09-20T00:00:00.000", + "Products.category": "Furniture", + "Products.productName": "Global Adaptabilites Bookcase, Cherry/Storm Gray Finish", + "Products.subCategory": "Bookcases", }, Object { - "BigECommerce.count": null, - "BigECommerce.totalCountRetailWeekAgo": "1", - "RetailCalendar.retail_date": "2020-09-27T00:00:00.000", - "RetailCalendar.retail_date.week": "2020-09-27T00:00:00.000", + "Products.category": "Furniture", + "Products.productName": "Linden 10 Round Wall Clock, Black", + "Products.subCategory": "Furnishings", }, Object { - "BigECommerce.count": "1", - "BigECommerce.totalCountRetailWeekAgo": null, - "RetailCalendar.retail_date": "2020-10-11T00:00:00.000", - "RetailCalendar.retail_date.week": "2020-10-11T00:00:00.000", + "Products.category": "Furniture", + "Products.productName": "Magna Visual Magnetic Picture Hangers", + "Products.subCategory": "Furnishings", }, Object { - "BigECommerce.count": "2", - "BigECommerce.totalCountRetailWeekAgo": "1", - "RetailCalendar.retail_date": "2020-10-18T00:00:00.000", - "RetailCalendar.retail_date.week": "2020-10-18T00:00:00.000", + "Products.category": "Furniture", + "Products.productName": "Anderson Hickey Conga Table Tops & Accessories", + "Products.subCategory": "Tables", }, Object { - "BigECommerce.count": "1", - "BigECommerce.totalCountRetailWeekAgo": "2", - "RetailCalendar.retail_date": "2020-10-25T00:00:00.000", - "RetailCalendar.retail_date.week": "2020-10-25T00:00:00.000", + "Products.category": "Furniture", + "Products.productName": "Balt Solid Wood Rectangular Table", + "Products.subCategory": "Tables", }, Object { - "BigECommerce.count": "3", - "BigECommerce.totalCountRetailWeekAgo": "1", - "RetailCalendar.retail_date": "2020-11-01T00:00:00.000", - "RetailCalendar.retail_date.week": "2020-11-01T00:00:00.000", + "Products.category": "Office Supplies", + "Products.productName": "Tyvek Side-Opening Peel & Seel Expanding Envelopes", + "Products.subCategory": "Envelopes", }, Object { - "BigECommerce.count": "2", - "BigECommerce.totalCountRetailWeekAgo": "3", - "RetailCalendar.retail_date": "2020-11-08T00:00:00.000", - "RetailCalendar.retail_date.week": "2020-11-08T00:00:00.000", + "Products.category": "Office Supplies", + "Products.productName": "Wausau Papers Astrobrights Colored Envelopes", + "Products.subCategory": "Envelopes", }, Object { - "BigECommerce.count": "3", - "BigECommerce.totalCountRetailWeekAgo": "2", - "RetailCalendar.retail_date": "2020-11-15T00:00:00.000", - "RetailCalendar.retail_date.week": "2020-11-15T00:00:00.000", + "Products.category": "Technology", + "Products.productName": "Kingston Digital DataTraveler 16GB USB 2.0", + "Products.subCategory": "Accessories", }, Object { - "BigECommerce.count": "1", - "BigECommerce.totalCountRetailWeekAgo": "3", - "RetailCalendar.retail_date": "2020-11-22T00:00:00.000", - "RetailCalendar.retail_date.week": "2020-11-22T00:00:00.000", + "Products.category": "Technology", + "Products.productName": "Kingston Digital DataTraveler 16GB USB 2.1", + "Products.subCategory": "Accessories", }, Object { - "BigECommerce.count": "3", - "BigECommerce.totalCountRetailWeekAgo": "1", - "RetailCalendar.retail_date": "2020-11-29T00:00:00.000", - "RetailCalendar.retail_date.week": "2020-11-29T00:00:00.000", + "Products.category": "Technology", + "Products.productName": "Kingston Digital DataTraveler 16GB USB 2.2", + "Products.subCategory": "Accessories", }, Object { - "BigECommerce.count": null, - "BigECommerce.totalCountRetailWeekAgo": "3", - "RetailCalendar.retail_date": "2020-12-06T00:00:00.000", - "RetailCalendar.retail_date.week": "2020-12-06T00:00:00.000", + "Products.category": "Technology", + "Products.productName": "Logitech di_Novo Edge Keyboard", + "Products.subCategory": "Accessories", }, Object { - "BigECommerce.count": "2", - "BigECommerce.totalCountRetailWeekAgo": null, - "RetailCalendar.retail_date": "2020-12-13T00:00:00.000", - "RetailCalendar.retail_date.week": "2020-12-13T00:00:00.000", + "Products.category": "Technology", + "Products.productName": "Lexmark 20R1285 X6650 Wireless All-in-One Printer", + "Products.subCategory": "Machines", }, Object { - "BigECommerce.count": "2", - "BigECommerce.totalCountRetailWeekAgo": "2", - "RetailCalendar.retail_date": "2020-12-20T00:00:00.000", - "RetailCalendar.retail_date.week": "2020-12-20T00:00:00.000", + "Products.category": "Technology", + "Products.productName": "Okidata C610n Printer", + "Products.subCategory": "Machines", }, Object { - "BigECommerce.count": null, - "BigECommerce.totalCountRetailWeekAgo": "2", - "RetailCalendar.retail_date": "2020-12-27T00:00:00.000", - "RetailCalendar.retail_date.week": "2020-12-27T00:00:00.000", + "Products.category": "Technology", + "Products.productName": "Google Nexus 5", + "Products.subCategory": "Phones", }, -] -`; - -exports[`Queries with the @cubejs-backend/athena-driver Tesseract: SQL API: Timeshift measure from cube 1`] = ` -Array [ Object { - "orderDate": 2020-01-01T00:00:00.000Z, - "totalQuantity": 6, - "totalQuantityPriorMonth": null, + "Products.category": "Technology", + "Products.productName": "Google Nexus 6", + "Products.subCategory": "Phones", }, Object { - "orderDate": 2020-02-01T00:00:00.000Z, - "totalQuantity": 2, - "totalQuantityPriorMonth": 6, + "Products.category": "Technology", + "Products.productName": "Google Nexus 7", + "Products.subCategory": "Phones", }, Object { - "orderDate": 2020-03-01T00:00:00.000Z, - "totalQuantity": 13, - "totalQuantityPriorMonth": 2, + "Products.category": "Technology", + "Products.productName": "HTC One", + "Products.subCategory": "Phones", }, +] +`; + +exports[`Queries with the @cubejs-backend/athena-driver filtering Products: endsWith filter + dimensions + order, third 1`] = `Array []`; + +exports[`Queries with the @cubejs-backend/athena-driver filtering Products: startsWith filter + dimensions + order, first 1`] = ` +Array [ Object { - "orderDate": 2020-04-01T00:00:00.000Z, - "totalQuantity": 3, - "totalQuantityPriorMonth": 13, + "Products.category": "Office Supplies", + "Products.productName": "OIC #2 Pencils, Medium Soft", + "Products.subCategory": "Art", }, Object { - "orderDate": 2020-05-01T00:00:00.000Z, - "totalQuantity": 15, - "totalQuantityPriorMonth": 3, + "Products.category": "Technology", + "Products.productName": "Okidata C610n Printer", + "Products.subCategory": "Machines", }, +] +`; + +exports[`Queries with the @cubejs-backend/athena-driver filtering Products: startsWith filter + dimensions + order, second 1`] = ` +Array [ Object { - "orderDate": 2020-06-01T00:00:00.000Z, - "totalQuantity": 18, - "totalQuantityPriorMonth": 15, + "Products.category": "Office Supplies", + "Products.productName": "OIC #2 Pencils, Medium Soft", + "Products.subCategory": "Art", }, Object { - "orderDate": 2020-07-01T00:00:00.000Z, - "totalQuantity": null, - "totalQuantityPriorMonth": 18, + "Products.category": "Technology", + "Products.productName": "Kingston Digital DataTraveler 16GB USB 2.0", + "Products.subCategory": "Accessories", }, Object { - "orderDate": 2020-09-01T00:00:00.000Z, - "totalQuantity": 27, - "totalQuantityPriorMonth": null, + "Products.category": "Technology", + "Products.productName": "Kingston Digital DataTraveler 16GB USB 2.1", + "Products.subCategory": "Accessories", }, Object { - "orderDate": 2020-10-01T00:00:00.000Z, - "totalQuantity": 11, - "totalQuantityPriorMonth": 27, + "Products.category": "Technology", + "Products.productName": "Kingston Digital DataTraveler 16GB USB 2.2", + "Products.subCategory": "Accessories", }, Object { - "orderDate": 2020-11-01T00:00:00.000Z, - "totalQuantity": 43, - "totalQuantityPriorMonth": 11, + "Products.category": "Technology", + "Products.productName": "Okidata C610n Printer", + "Products.subCategory": "Machines", }, +] +`; + +exports[`Queries with the @cubejs-backend/athena-driver filtering Products: startsWith filter + dimensions + order, third 1`] = `Array []`; + +exports[`Queries with the @cubejs-backend/athena-driver pre-aggregations Customers: running total without time dimension 1`] = ` +Array [ Object { - "orderDate": 2020-12-01T00:00:00.000Z, - "totalQuantity": 22, - "totalQuantityPriorMonth": 43, + "Customers.runningTotal": "41", }, ] `; @@ -3524,6 +3449,81 @@ Array [ ] `; +exports[`Queries with the @cubejs-backend/athena-driver querying BigECommerce: multi-stage group by time dimension 1`] = ` +Array [ + Object { + "BigECommerce.orderDate": "2020-01-01T00:00:00.000", + "BigECommerce.orderDate.month": "2020-01-01T00:00:00.000", + "BigECommerce.orderDate.quarter": "2020-01-01T00:00:00.000", + "BigECommerce.totalProfit": "29.65480", + "BigECommerce.totalProfitForQuarter": "619.44850", + }, + Object { + "BigECommerce.orderDate": "2020-02-01T00:00:00.000", + "BigECommerce.orderDate.month": "2020-02-01T00:00:00.000", + "BigECommerce.orderDate.quarter": "2020-01-01T00:00:00.000", + "BigECommerce.totalProfit": "6.19920", + "BigECommerce.totalProfitForQuarter": "619.44850", + }, + Object { + "BigECommerce.orderDate": "2020-03-01T00:00:00.000", + "BigECommerce.orderDate.month": "2020-03-01T00:00:00.000", + "BigECommerce.orderDate.quarter": "2020-01-01T00:00:00.000", + "BigECommerce.totalProfit": "583.59450", + "BigECommerce.totalProfitForQuarter": "619.44850", + }, + Object { + "BigECommerce.orderDate": "2020-04-01T00:00:00.000", + "BigECommerce.orderDate.month": "2020-04-01T00:00:00.000", + "BigECommerce.orderDate.quarter": "2020-04-01T00:00:00.000", + "BigECommerce.totalProfit": "6.41760", + "BigECommerce.totalProfitForQuarter": "394.33860", + }, + Object { + "BigECommerce.orderDate": "2020-05-01T00:00:00.000", + "BigECommerce.orderDate.month": "2020-05-01T00:00:00.000", + "BigECommerce.orderDate.quarter": "2020-04-01T00:00:00.000", + "BigECommerce.totalProfit": "353.68490", + "BigECommerce.totalProfitForQuarter": "394.33860", + }, + Object { + "BigECommerce.orderDate": "2020-06-01T00:00:00.000", + "BigECommerce.orderDate.month": "2020-06-01T00:00:00.000", + "BigECommerce.orderDate.quarter": "2020-04-01T00:00:00.000", + "BigECommerce.totalProfit": "34.23610", + "BigECommerce.totalProfitForQuarter": "394.33860", + }, + Object { + "BigECommerce.orderDate": "2020-09-01T00:00:00.000", + "BigECommerce.orderDate.month": "2020-09-01T00:00:00.000", + "BigECommerce.orderDate.quarter": "2020-07-01T00:00:00.000", + "BigECommerce.totalProfit": "461.13320", + "BigECommerce.totalProfitForQuarter": "461.13320", + }, + Object { + "BigECommerce.orderDate": "2020-10-01T00:00:00.000", + "BigECommerce.orderDate.month": "2020-10-01T00:00:00.000", + "BigECommerce.orderDate.quarter": "2020-10-01T00:00:00.000", + "BigECommerce.totalProfit": "139.99700", + "BigECommerce.totalProfitForQuarter": "1576.63240", + }, + Object { + "BigECommerce.orderDate": "2020-11-01T00:00:00.000", + "BigECommerce.orderDate.month": "2020-11-01T00:00:00.000", + "BigECommerce.orderDate.quarter": "2020-10-01T00:00:00.000", + "BigECommerce.totalProfit": "1132.66170", + "BigECommerce.totalProfitForQuarter": "1576.63240", + }, + Object { + "BigECommerce.orderDate": "2020-12-01T00:00:00.000", + "BigECommerce.orderDate.month": "2020-12-01T00:00:00.000", + "BigECommerce.orderDate.quarter": "2020-10-01T00:00:00.000", + "BigECommerce.totalProfit": "303.97370", + "BigECommerce.totalProfitForQuarter": "1576.63240", + }, +] +`; + exports[`Queries with the @cubejs-backend/athena-driver querying BigECommerce: partitioned pre-agg with multi time dimension 1`] = ` Array [ Object { @@ -9549,6 +9549,111 @@ Array [ ] `; +exports[`Queries with the @cubejs-backend/athena-driver querying SwitchSourceTest: filter by switch dimensions 1`] = ` +Array [ + Object { + "SwitchSourceTest.city": "Detroit", + "SwitchSourceTest.orderDate": "2020-01-01T00:00:00.000", + "SwitchSourceTest.orderDate.month": "2020-01-01T00:00:00.000", + "SwitchSourceTest.totalSales": "210.98", + }, + Object { + "SwitchSourceTest.city": "Lorain", + "SwitchSourceTest.orderDate": "2020-01-01T00:00:00.000", + "SwitchSourceTest.orderDate.month": "2020-01-01T00:00:00.000", + "SwitchSourceTest.totalSales": "48.896", + }, + Object { + "SwitchSourceTest.city": "Decatur", + "SwitchSourceTest.orderDate": "2020-02-01T00:00:00.000", + "SwitchSourceTest.orderDate.month": "2020-02-01T00:00:00.000", + "SwitchSourceTest.totalSales": "18.368", + }, + Object { + "SwitchSourceTest.city": "Houston", + "SwitchSourceTest.orderDate": "2020-03-01T00:00:00.000", + "SwitchSourceTest.orderDate.month": "2020-03-01T00:00:00.000", + "SwitchSourceTest.totalSales": "2399.96", + }, + Object { + "SwitchSourceTest.city": "New York City", + "SwitchSourceTest.orderDate": "2020-03-01T00:00:00.000", + "SwitchSourceTest.orderDate.month": "2020-03-01T00:00:00.000", + "SwitchSourceTest.totalSales": "71.6", + }, +] +`; + +exports[`Queries with the @cubejs-backend/athena-driver querying SwitchSourceTest: full cross join 1`] = ` +Array [ + Object { + "SwitchSourceTest.city": "Detroit", + "SwitchSourceTest.orderDate": "2020-01-01T00:00:00.000", + "SwitchSourceTest.orderDate.month": "2020-01-01T00:00:00.000", + "SwitchSourceTest.totalSales": "1265.8799999999999", + }, + Object { + "SwitchSourceTest.city": "Lorain", + "SwitchSourceTest.orderDate": "2020-01-01T00:00:00.000", + "SwitchSourceTest.orderDate.month": "2020-01-01T00:00:00.000", + "SwitchSourceTest.totalSales": "293.376", + }, + Object { + "SwitchSourceTest.city": "Decatur", + "SwitchSourceTest.orderDate": "2020-02-01T00:00:00.000", + "SwitchSourceTest.orderDate.month": "2020-02-01T00:00:00.000", + "SwitchSourceTest.totalSales": "110.208", + }, + Object { + "SwitchSourceTest.city": "Houston", + "SwitchSourceTest.orderDate": "2020-03-01T00:00:00.000", + "SwitchSourceTest.orderDate.month": "2020-03-01T00:00:00.000", + "SwitchSourceTest.totalSales": "14399.76", + }, + Object { + "SwitchSourceTest.city": "New York City", + "SwitchSourceTest.orderDate": "2020-03-01T00:00:00.000", + "SwitchSourceTest.orderDate.month": "2020-03-01T00:00:00.000", + "SwitchSourceTest.totalSales": "429.59999999999997", + }, +] +`; + +exports[`Queries with the @cubejs-backend/athena-driver querying SwitchSourceTest: simple cross join 1`] = ` +Array [ + Object { + "SwitchSourceTest.city": "Detroit", + "SwitchSourceTest.orderDate": "2020-01-01T00:00:00.000", + "SwitchSourceTest.orderDate.month": "2020-01-01T00:00:00.000", + "SwitchSourceTest.totalSalesA": "421.96", + }, + Object { + "SwitchSourceTest.city": "Lorain", + "SwitchSourceTest.orderDate": "2020-01-01T00:00:00.000", + "SwitchSourceTest.orderDate.month": "2020-01-01T00:00:00.000", + "SwitchSourceTest.totalSalesA": "97.792", + }, + Object { + "SwitchSourceTest.city": "Decatur", + "SwitchSourceTest.orderDate": "2020-02-01T00:00:00.000", + "SwitchSourceTest.orderDate.month": "2020-02-01T00:00:00.000", + "SwitchSourceTest.totalSalesA": "36.736", + }, + Object { + "SwitchSourceTest.city": "Houston", + "SwitchSourceTest.orderDate": "2020-03-01T00:00:00.000", + "SwitchSourceTest.orderDate.month": "2020-03-01T00:00:00.000", + "SwitchSourceTest.totalSalesA": "4799.92", + }, + Object { + "SwitchSourceTest.city": "New York City", + "SwitchSourceTest.orderDate": "2020-03-01T00:00:00.000", + "SwitchSourceTest.orderDate.month": "2020-03-01T00:00:00.000", + "SwitchSourceTest.totalSalesA": "143.2", + }, +] +`; + exports[`Queries with the @cubejs-backend/athena-driver querying custom granularities (with preaggregation) ECommerce: totalQuantity by half_year + dimension 1`] = ` Array [ Object { diff --git a/packages/cubejs-testing-drivers/test/__snapshots__/bigquery-export-bucket-gcs-full.test.ts.snap b/packages/cubejs-testing-drivers/test/__snapshots__/bigquery-export-bucket-gcs-full.test.ts.snap index 18ce55e51a583..f907c6d10569f 100644 --- a/packages/cubejs-testing-drivers/test/__snapshots__/bigquery-export-bucket-gcs-full.test.ts.snap +++ b/packages/cubejs-testing-drivers/test/__snapshots__/bigquery-export-bucket-gcs-full.test.ts.snap @@ -30,81 +30,6 @@ Array [ ] `; -exports[`Queries with the @cubejs-backend/bigquery-driver querying BigECommerce: multi-stage group by time dimension 1`] = ` -Array [ - Object { - "BigECommerce.orderDate": "2020-01-01T00:00:00.000", - "BigECommerce.orderDate.month": "2020-01-01T00:00:00.000", - "BigECommerce.orderDate.quarter": "2020-01-01T00:00:00.000", - "BigECommerce.totalProfit": "29.65480", - "BigECommerce.totalProfitForQuarter": "619.44850", - }, - Object { - "BigECommerce.orderDate": "2020-02-01T00:00:00.000", - "BigECommerce.orderDate.month": "2020-02-01T00:00:00.000", - "BigECommerce.orderDate.quarter": "2020-01-01T00:00:00.000", - "BigECommerce.totalProfit": "6.19920", - "BigECommerce.totalProfitForQuarter": "619.44850", - }, - Object { - "BigECommerce.orderDate": "2020-03-01T00:00:00.000", - "BigECommerce.orderDate.month": "2020-03-01T00:00:00.000", - "BigECommerce.orderDate.quarter": "2020-01-01T00:00:00.000", - "BigECommerce.totalProfit": "583.59450", - "BigECommerce.totalProfitForQuarter": "619.44850", - }, - Object { - "BigECommerce.orderDate": "2020-04-01T00:00:00.000", - "BigECommerce.orderDate.month": "2020-04-01T00:00:00.000", - "BigECommerce.orderDate.quarter": "2020-04-01T00:00:00.000", - "BigECommerce.totalProfit": "6.41760", - "BigECommerce.totalProfitForQuarter": "394.33860", - }, - Object { - "BigECommerce.orderDate": "2020-05-01T00:00:00.000", - "BigECommerce.orderDate.month": "2020-05-01T00:00:00.000", - "BigECommerce.orderDate.quarter": "2020-04-01T00:00:00.000", - "BigECommerce.totalProfit": "353.68490", - "BigECommerce.totalProfitForQuarter": "394.33860", - }, - Object { - "BigECommerce.orderDate": "2020-06-01T00:00:00.000", - "BigECommerce.orderDate.month": "2020-06-01T00:00:00.000", - "BigECommerce.orderDate.quarter": "2020-04-01T00:00:00.000", - "BigECommerce.totalProfit": "34.23610", - "BigECommerce.totalProfitForQuarter": "394.33860", - }, - Object { - "BigECommerce.orderDate": "2020-09-01T00:00:00.000", - "BigECommerce.orderDate.month": "2020-09-01T00:00:00.000", - "BigECommerce.orderDate.quarter": "2020-07-01T00:00:00.000", - "BigECommerce.totalProfit": "461.13320", - "BigECommerce.totalProfitForQuarter": "461.13320", - }, - Object { - "BigECommerce.orderDate": "2020-10-01T00:00:00.000", - "BigECommerce.orderDate.month": "2020-10-01T00:00:00.000", - "BigECommerce.orderDate.quarter": "2020-10-01T00:00:00.000", - "BigECommerce.totalProfit": "139.99700", - "BigECommerce.totalProfitForQuarter": "1576.63240", - }, - Object { - "BigECommerce.orderDate": "2020-11-01T00:00:00.000", - "BigECommerce.orderDate.month": "2020-11-01T00:00:00.000", - "BigECommerce.orderDate.quarter": "2020-10-01T00:00:00.000", - "BigECommerce.totalProfit": "1132.66170", - "BigECommerce.totalProfitForQuarter": "1576.63240", - }, - Object { - "BigECommerce.orderDate": "2020-12-01T00:00:00.000", - "BigECommerce.orderDate.month": "2020-12-01T00:00:00.000", - "BigECommerce.orderDate.quarter": "2020-10-01T00:00:00.000", - "BigECommerce.totalProfit": "303.97370", - "BigECommerce.totalProfitForQuarter": "1576.63240", - }, -] -`; - exports[`Queries with the @cubejs-backend/bigquery-driver SQL API: Nested Rollup 1`] = ` Array [ Object { @@ -4052,176 +3977,335 @@ Array [ ] `; -exports[`Queries with the @cubejs-backend/bigquery-driver filtering Customers: contains + dimensions, first 1`] = ` +exports[`Queries with the @cubejs-backend/bigquery-driver Tesseract: SQL API: Timeshift measure from cube 1`] = ` Array [ Object { - "Customers.customerId": "AH-10465", - "Customers.customerName": "Customer 1", + "orderDate": 2020-01-01T00:00:00.000Z, + "totalQuantity": 6, + "totalQuantityPriorMonth": null, }, Object { - "Customers.customerId": "AJ-10780", - "Customers.customerName": "Customer 2", + "orderDate": 2020-02-01T00:00:00.000Z, + "totalQuantity": 2, + "totalQuantityPriorMonth": 6, }, Object { - "Customers.customerId": "AS-10225", - "Customers.customerName": "Customer 3", + "orderDate": 2020-03-01T00:00:00.000Z, + "totalQuantity": 13, + "totalQuantityPriorMonth": 2, }, Object { - "Customers.customerId": "AW-10840", - "Customers.customerName": "Customer 4", + "orderDate": 2020-04-01T00:00:00.000Z, + "totalQuantity": 3, + "totalQuantityPriorMonth": 13, }, Object { - "Customers.customerId": "BB-11545", - "Customers.customerName": "Customer 5", + "orderDate": 2020-05-01T00:00:00.000Z, + "totalQuantity": 15, + "totalQuantityPriorMonth": 3, }, Object { - "Customers.customerId": "BF-11020", - "Customers.customerName": "Customer 6", + "orderDate": 2020-06-01T00:00:00.000Z, + "totalQuantity": 18, + "totalQuantityPriorMonth": 15, }, Object { - "Customers.customerId": "BF-11170", - "Customers.customerName": "Customer 7", + "orderDate": 2020-07-01T00:00:00.000Z, + "totalQuantity": null, + "totalQuantityPriorMonth": 18, }, Object { - "Customers.customerId": "BM-11650", - "Customers.customerName": "Customer 8", + "orderDate": 2020-09-01T00:00:00.000Z, + "totalQuantity": 27, + "totalQuantityPriorMonth": null, }, Object { - "Customers.customerId": "BS-11380", - "Customers.customerName": "Customer 9", + "orderDate": 2020-10-01T00:00:00.000Z, + "totalQuantity": 11, + "totalQuantityPriorMonth": 27, }, Object { - "Customers.customerId": "BS-11755", - "Customers.customerName": "Customer 10", + "orderDate": 2020-11-01T00:00:00.000Z, + "totalQuantity": 43, + "totalQuantityPriorMonth": 11, }, Object { - "Customers.customerId": "CA-12775", - "Customers.customerName": "Customer 11", + "orderDate": 2020-12-01T00:00:00.000Z, + "totalQuantity": 22, + "totalQuantityPriorMonth": 43, }, +] +`; + +exports[`Queries with the @cubejs-backend/bigquery-driver Tesseract: querying BigECommerce with Retail Calendar: totalCountRetailMonthAgo 1`] = ` +Array [ Object { - "Customers.customerId": "CC-12475", - "Customers.customerName": "Customer 12", + "BigECommerce.count": 1, + "BigECommerce.totalCountRetailMonthAgo": 1, + "RetailCalendar.retail_date": "2020-02-01T00:00:00.000", + "RetailCalendar.retail_date.month": "2020-02-01T00:00:00.000", }, Object { - "Customers.customerId": "CD-12280", - "Customers.customerName": "Customer 13", + "BigECommerce.count": 2, + "BigECommerce.totalCountRetailMonthAgo": 1, + "RetailCalendar.retail_date": "2020-03-01T00:00:00.000", + "RetailCalendar.retail_date.month": "2020-03-01T00:00:00.000", }, Object { - "Customers.customerId": "CS-12355", - "Customers.customerName": "Customer 14", + "BigECommerce.count": 1, + "BigECommerce.totalCountRetailMonthAgo": 2, + "RetailCalendar.retail_date": "2020-04-01T00:00:00.000", + "RetailCalendar.retail_date.month": "2020-04-01T00:00:00.000", }, Object { - "Customers.customerId": "DB-13405", - "Customers.customerName": "Customer 15", + "BigECommerce.count": 5, + "BigECommerce.totalCountRetailMonthAgo": 1, + "RetailCalendar.retail_date": "2020-05-01T00:00:00.000", + "RetailCalendar.retail_date.month": "2020-05-01T00:00:00.000", }, Object { - "Customers.customerId": "DG-13300", - "Customers.customerName": "Customer 16", + "BigECommerce.count": 7, + "BigECommerce.totalCountRetailMonthAgo": 5, + "RetailCalendar.retail_date": "2020-06-01T00:00:00.000", + "RetailCalendar.retail_date.month": "2020-06-01T00:00:00.000", }, Object { - "Customers.customerId": "DW-13480", - "Customers.customerName": "Customer 17", + "BigECommerce.count": null, + "BigECommerce.totalCountRetailMonthAgo": 7, + "RetailCalendar.retail_date": "2020-07-01T00:00:00.000", + "RetailCalendar.retail_date.month": "2020-07-01T00:00:00.000", }, Object { - "Customers.customerId": "EM-14140", - "Customers.customerName": "Customer 18", + "BigECommerce.count": 6, + "BigECommerce.totalCountRetailMonthAgo": null, + "RetailCalendar.retail_date": "2020-09-01T00:00:00.000", + "RetailCalendar.retail_date.month": "2020-09-01T00:00:00.000", }, Object { - "Customers.customerId": "GA-14725", - "Customers.customerName": "Customer 19", + "BigECommerce.count": 4, + "BigECommerce.totalCountRetailMonthAgo": 6, + "RetailCalendar.retail_date": "2020-10-01T00:00:00.000", + "RetailCalendar.retail_date.month": "2020-10-01T00:00:00.000", }, Object { - "Customers.customerId": "GZ-14470", - "Customers.customerName": "Customer 20", + "BigECommerce.count": 9, + "BigECommerce.totalCountRetailMonthAgo": 5, + "RetailCalendar.retail_date": "2020-11-01T00:00:00.000", + "RetailCalendar.retail_date.month": "2020-11-01T00:00:00.000", }, Object { - "Customers.customerId": "HH-15010", - "Customers.customerName": "Customer 21", + "BigECommerce.count": 7, + "BigECommerce.totalCountRetailMonthAgo": 8, + "RetailCalendar.retail_date": "2020-12-01T00:00:00.000", + "RetailCalendar.retail_date.month": "2020-12-01T00:00:00.000", }, Object { - "Customers.customerId": "HK-14890", - "Customers.customerName": "Customer 22", + "BigECommerce.count": null, + "BigECommerce.totalCountRetailMonthAgo": 7, + "RetailCalendar.retail_date": "2021-01-01T00:00:00.000", + "RetailCalendar.retail_date.month": "2021-01-01T00:00:00.000", }, +] +`; + +exports[`Queries with the @cubejs-backend/bigquery-driver Tesseract: querying BigECommerce with Retail Calendar: totalCountRetailWeekAgo 1`] = ` +Array [ Object { - "Customers.customerId": "JH-15430", - "Customers.customerName": "Customer 23", + "BigECommerce.count": 1, + "BigECommerce.totalCountRetailWeekAgo": null, + "RetailCalendar.retail_date": "2020-02-16T00:00:00.000", + "RetailCalendar.retail_date.week": "2020-02-16T00:00:00.000", }, Object { - "Customers.customerId": "JO-15550", - "Customers.customerName": "Customer 24", + "BigECommerce.count": null, + "BigECommerce.totalCountRetailWeekAgo": 1, + "RetailCalendar.retail_date": "2020-02-23T00:00:00.000", + "RetailCalendar.retail_date.week": "2020-02-23T00:00:00.000", }, Object { - "Customers.customerId": "JS-16030", - "Customers.customerName": "Customer 25", + "BigECommerce.count": 1, + "BigECommerce.totalCountRetailWeekAgo": null, + "RetailCalendar.retail_date": "2020-03-15T00:00:00.000", + "RetailCalendar.retail_date.week": "2020-03-15T00:00:00.000", }, Object { - "Customers.customerId": "JW-15220", - "Customers.customerName": "Customer 26", + "BigECommerce.count": 1, + "BigECommerce.totalCountRetailWeekAgo": 1, + "RetailCalendar.retail_date": "2020-03-22T00:00:00.000", + "RetailCalendar.retail_date.week": "2020-03-22T00:00:00.000", }, Object { - "Customers.customerId": "KL-16555", - "Customers.customerName": "Customer 27", + "BigECommerce.count": null, + "BigECommerce.totalCountRetailWeekAgo": 1, + "RetailCalendar.retail_date": "2020-03-29T00:00:00.000", + "RetailCalendar.retail_date.week": "2020-03-29T00:00:00.000", }, Object { - "Customers.customerId": "KN-16705", - "Customers.customerName": "Customer 28", + "BigECommerce.count": 1, + "BigECommerce.totalCountRetailWeekAgo": null, + "RetailCalendar.retail_date": "2020-04-05T00:00:00.000", + "RetailCalendar.retail_date.week": "2020-04-05T00:00:00.000", }, Object { - "Customers.customerId": "LC-17050", - "Customers.customerName": "Customer 29", + "BigECommerce.count": null, + "BigECommerce.totalCountRetailWeekAgo": 1, + "RetailCalendar.retail_date": "2020-04-12T00:00:00.000", + "RetailCalendar.retail_date.week": "2020-04-12T00:00:00.000", }, Object { - "Customers.customerId": "LR-16915", - "Customers.customerName": "Customer 30", + "BigECommerce.count": 3, + "BigECommerce.totalCountRetailWeekAgo": null, + "RetailCalendar.retail_date": "2020-05-10T00:00:00.000", + "RetailCalendar.retail_date.week": "2020-05-10T00:00:00.000", }, Object { - "Customers.customerId": "MC-17605", - "Customers.customerName": "Customer 31", + "BigECommerce.count": null, + "BigECommerce.totalCountRetailWeekAgo": 3, + "RetailCalendar.retail_date": "2020-05-17T00:00:00.000", + "RetailCalendar.retail_date.week": "2020-05-17T00:00:00.000", }, Object { - "Customers.customerId": "MG-17650", - "Customers.customerName": "Customer 32", + "BigECommerce.count": 2, + "BigECommerce.totalCountRetailWeekAgo": null, + "RetailCalendar.retail_date": "2020-05-24T00:00:00.000", + "RetailCalendar.retail_date.week": "2020-05-24T00:00:00.000", }, Object { - "Customers.customerId": "ML-17755", - "Customers.customerName": "Customer 33", + "BigECommerce.count": 1, + "BigECommerce.totalCountRetailWeekAgo": 2, + "RetailCalendar.retail_date": "2020-05-31T00:00:00.000", + "RetailCalendar.retail_date.week": "2020-05-31T00:00:00.000", }, Object { - "Customers.customerId": "MM-18280", - "Customers.customerName": "Customer 34", + "BigECommerce.count": 2, + "BigECommerce.totalCountRetailWeekAgo": 1, + "RetailCalendar.retail_date": "2020-06-07T00:00:00.000", + "RetailCalendar.retail_date.week": "2020-06-07T00:00:00.000", }, Object { - "Customers.customerId": "NP-18670", - "Customers.customerName": "Customer 35", + "BigECommerce.count": 2, + "BigECommerce.totalCountRetailWeekAgo": 2, + "RetailCalendar.retail_date": "2020-06-14T00:00:00.000", + "RetailCalendar.retail_date.week": "2020-06-14T00:00:00.000", }, Object { - "Customers.customerId": "PF-19165", - "Customers.customerName": "Customer 36", + "BigECommerce.count": 2, + "BigECommerce.totalCountRetailWeekAgo": 2, + "RetailCalendar.retail_date": "2020-06-21T00:00:00.000", + "RetailCalendar.retail_date.week": "2020-06-21T00:00:00.000", }, Object { - "Customers.customerId": "SB-20185", - "Customers.customerName": "Customer 37", + "BigECommerce.count": null, + "BigECommerce.totalCountRetailWeekAgo": 2, + "RetailCalendar.retail_date": "2020-06-28T00:00:00.000", + "RetailCalendar.retail_date.week": "2020-06-28T00:00:00.000", }, Object { - "Customers.customerId": "SS-20140", - "Customers.customerName": "Customer 38", + "BigECommerce.count": 2, + "BigECommerce.totalCountRetailWeekAgo": null, + "RetailCalendar.retail_date": "2020-08-30T00:00:00.000", + "RetailCalendar.retail_date.week": "2020-08-30T00:00:00.000", }, Object { - "Customers.customerId": "TB-21175", - "Customers.customerName": "Customer 39", + "BigECommerce.count": 1, + "BigECommerce.totalCountRetailWeekAgo": 2, + "RetailCalendar.retail_date": "2020-09-06T00:00:00.000", + "RetailCalendar.retail_date.week": "2020-09-06T00:00:00.000", }, Object { - "Customers.customerId": "TS-21205", - "Customers.customerName": "Customer 40", + "BigECommerce.count": 2, + "BigECommerce.totalCountRetailWeekAgo": 1, + "RetailCalendar.retail_date": "2020-09-13T00:00:00.000", + "RetailCalendar.retail_date.week": "2020-09-13T00:00:00.000", }, Object { - "Customers.customerId": "WB-21850", - "Customers.customerName": "Customer 41", + "BigECommerce.count": 1, + "BigECommerce.totalCountRetailWeekAgo": 2, + "RetailCalendar.retail_date": "2020-09-20T00:00:00.000", + "RetailCalendar.retail_date.week": "2020-09-20T00:00:00.000", + }, + Object { + "BigECommerce.count": null, + "BigECommerce.totalCountRetailWeekAgo": 1, + "RetailCalendar.retail_date": "2020-09-27T00:00:00.000", + "RetailCalendar.retail_date.week": "2020-09-27T00:00:00.000", + }, + Object { + "BigECommerce.count": 1, + "BigECommerce.totalCountRetailWeekAgo": null, + "RetailCalendar.retail_date": "2020-10-11T00:00:00.000", + "RetailCalendar.retail_date.week": "2020-10-11T00:00:00.000", + }, + Object { + "BigECommerce.count": 2, + "BigECommerce.totalCountRetailWeekAgo": 1, + "RetailCalendar.retail_date": "2020-10-18T00:00:00.000", + "RetailCalendar.retail_date.week": "2020-10-18T00:00:00.000", + }, + Object { + "BigECommerce.count": 1, + "BigECommerce.totalCountRetailWeekAgo": 2, + "RetailCalendar.retail_date": "2020-10-25T00:00:00.000", + "RetailCalendar.retail_date.week": "2020-10-25T00:00:00.000", + }, + Object { + "BigECommerce.count": 3, + "BigECommerce.totalCountRetailWeekAgo": 1, + "RetailCalendar.retail_date": "2020-11-01T00:00:00.000", + "RetailCalendar.retail_date.week": "2020-11-01T00:00:00.000", + }, + Object { + "BigECommerce.count": 2, + "BigECommerce.totalCountRetailWeekAgo": 3, + "RetailCalendar.retail_date": "2020-11-08T00:00:00.000", + "RetailCalendar.retail_date.week": "2020-11-08T00:00:00.000", + }, + Object { + "BigECommerce.count": 3, + "BigECommerce.totalCountRetailWeekAgo": 2, + "RetailCalendar.retail_date": "2020-11-15T00:00:00.000", + "RetailCalendar.retail_date.week": "2020-11-15T00:00:00.000", + }, + Object { + "BigECommerce.count": 1, + "BigECommerce.totalCountRetailWeekAgo": 3, + "RetailCalendar.retail_date": "2020-11-22T00:00:00.000", + "RetailCalendar.retail_date.week": "2020-11-22T00:00:00.000", + }, + Object { + "BigECommerce.count": 3, + "BigECommerce.totalCountRetailWeekAgo": 1, + "RetailCalendar.retail_date": "2020-11-29T00:00:00.000", + "RetailCalendar.retail_date.week": "2020-11-29T00:00:00.000", + }, + Object { + "BigECommerce.count": null, + "BigECommerce.totalCountRetailWeekAgo": 3, + "RetailCalendar.retail_date": "2020-12-06T00:00:00.000", + "RetailCalendar.retail_date.week": "2020-12-06T00:00:00.000", + }, + Object { + "BigECommerce.count": 2, + "BigECommerce.totalCountRetailWeekAgo": null, + "RetailCalendar.retail_date": "2020-12-13T00:00:00.000", + "RetailCalendar.retail_date.week": "2020-12-13T00:00:00.000", + }, + Object { + "BigECommerce.count": 2, + "BigECommerce.totalCountRetailWeekAgo": 2, + "RetailCalendar.retail_date": "2020-12-20T00:00:00.000", + "RetailCalendar.retail_date.week": "2020-12-20T00:00:00.000", + }, + Object { + "BigECommerce.count": null, + "BigECommerce.totalCountRetailWeekAgo": 2, + "RetailCalendar.retail_date": "2020-12-27T00:00:00.000", + "RetailCalendar.retail_date.week": "2020-12-27T00:00:00.000", }, ] `; -exports[`Queries with the @cubejs-backend/bigquery-driver filtering Customers: contains + dimensions, second 1`] = ` +exports[`Queries with the @cubejs-backend/bigquery-driver filtering Customers: contains + dimensions, first 1`] = ` Array [ Object { "Customers.customerId": "AH-10465", @@ -4390,106 +4474,7 @@ Array [ ] `; -exports[`Queries with the @cubejs-backend/bigquery-driver filtering Customers: contains + dimensions, third 1`] = `Array []`; - -exports[`Queries with the @cubejs-backend/bigquery-driver filtering Customers: endsWith filter + dimensions, first 1`] = ` -Array [ - Object { - "Customers.customerId": "AJ-10780", - "Customers.customerName": "Customer 2", - }, - Object { - "Customers.customerId": "AW-10840", - "Customers.customerName": "Customer 4", - }, - Object { - "Customers.customerId": "BF-11020", - "Customers.customerName": "Customer 6", - }, - Object { - "Customers.customerId": "BF-11170", - "Customers.customerName": "Customer 7", - }, - Object { - "Customers.customerId": "BM-11650", - "Customers.customerName": "Customer 8", - }, - Object { - "Customers.customerId": "BS-11380", - "Customers.customerName": "Customer 9", - }, - Object { - "Customers.customerId": "CD-12280", - "Customers.customerName": "Customer 13", - }, - Object { - "Customers.customerId": "DG-13300", - "Customers.customerName": "Customer 16", - }, - Object { - "Customers.customerId": "DW-13480", - "Customers.customerName": "Customer 17", - }, - Object { - "Customers.customerId": "EM-14140", - "Customers.customerName": "Customer 18", - }, - Object { - "Customers.customerId": "GZ-14470", - "Customers.customerName": "Customer 20", - }, - Object { - "Customers.customerId": "HH-15010", - "Customers.customerName": "Customer 21", - }, - Object { - "Customers.customerId": "HK-14890", - "Customers.customerName": "Customer 22", - }, - Object { - "Customers.customerId": "JH-15430", - "Customers.customerName": "Customer 23", - }, - Object { - "Customers.customerId": "JO-15550", - "Customers.customerName": "Customer 24", - }, - Object { - "Customers.customerId": "JS-16030", - "Customers.customerName": "Customer 25", - }, - Object { - "Customers.customerId": "JW-15220", - "Customers.customerName": "Customer 26", - }, - Object { - "Customers.customerId": "LC-17050", - "Customers.customerName": "Customer 29", - }, - Object { - "Customers.customerId": "MG-17650", - "Customers.customerName": "Customer 32", - }, - Object { - "Customers.customerId": "MM-18280", - "Customers.customerName": "Customer 34", - }, - Object { - "Customers.customerId": "NP-18670", - "Customers.customerName": "Customer 35", - }, - Object { - "Customers.customerId": "SS-20140", - "Customers.customerName": "Customer 38", - }, - Object { - "Customers.customerId": "WB-21850", - "Customers.customerName": "Customer 41", - }, -] -`; - -exports[`Queries with the @cubejs-backend/bigquery-driver filtering Customers: endsWith filter + dimensions, second 1`] = ` +exports[`Queries with the @cubejs-backend/bigquery-driver filtering Customers: contains + dimensions, second 1`] = ` Array [ Object { "Customers.customerId": "AH-10465", @@ -4658,88 +4643,106 @@ Array [ ] `; -exports[`Queries with the @cubejs-backend/bigquery-driver filtering Customers: endsWith filter + dimensions, third 1`] = `Array []`; +exports[`Queries with the @cubejs-backend/bigquery-driver filtering Customers: contains + dimensions, third 1`] = `Array []`; -exports[`Queries with the @cubejs-backend/bigquery-driver filtering Customers: notEndsWith filter + dimensions, first 1`] = ` +exports[`Queries with the @cubejs-backend/bigquery-driver filtering Customers: endsWith filter + dimensions, first 1`] = ` Array [ Object { - "Customers.customerId": "AH-10465", - "Customers.customerName": "Customer 1", + "Customers.customerId": "AJ-10780", + "Customers.customerName": "Customer 2", }, Object { - "Customers.customerId": "AS-10225", - "Customers.customerName": "Customer 3", + "Customers.customerId": "AW-10840", + "Customers.customerName": "Customer 4", }, Object { - "Customers.customerId": "BB-11545", - "Customers.customerName": "Customer 5", + "Customers.customerId": "BF-11020", + "Customers.customerName": "Customer 6", }, Object { - "Customers.customerId": "BS-11755", - "Customers.customerName": "Customer 10", + "Customers.customerId": "BF-11170", + "Customers.customerName": "Customer 7", }, Object { - "Customers.customerId": "CA-12775", - "Customers.customerName": "Customer 11", + "Customers.customerId": "BM-11650", + "Customers.customerName": "Customer 8", }, Object { - "Customers.customerId": "CC-12475", - "Customers.customerName": "Customer 12", + "Customers.customerId": "BS-11380", + "Customers.customerName": "Customer 9", }, Object { - "Customers.customerId": "CS-12355", - "Customers.customerName": "Customer 14", + "Customers.customerId": "CD-12280", + "Customers.customerName": "Customer 13", }, Object { - "Customers.customerId": "DB-13405", - "Customers.customerName": "Customer 15", + "Customers.customerId": "DG-13300", + "Customers.customerName": "Customer 16", }, Object { - "Customers.customerId": "GA-14725", - "Customers.customerName": "Customer 19", + "Customers.customerId": "DW-13480", + "Customers.customerName": "Customer 17", }, Object { - "Customers.customerId": "KL-16555", - "Customers.customerName": "Customer 27", + "Customers.customerId": "EM-14140", + "Customers.customerName": "Customer 18", }, Object { - "Customers.customerId": "KN-16705", - "Customers.customerName": "Customer 28", + "Customers.customerId": "GZ-14470", + "Customers.customerName": "Customer 20", }, Object { - "Customers.customerId": "LR-16915", - "Customers.customerName": "Customer 30", + "Customers.customerId": "HH-15010", + "Customers.customerName": "Customer 21", }, Object { - "Customers.customerId": "MC-17605", - "Customers.customerName": "Customer 31", + "Customers.customerId": "HK-14890", + "Customers.customerName": "Customer 22", }, Object { - "Customers.customerId": "ML-17755", - "Customers.customerName": "Customer 33", + "Customers.customerId": "JH-15430", + "Customers.customerName": "Customer 23", }, Object { - "Customers.customerId": "PF-19165", - "Customers.customerName": "Customer 36", + "Customers.customerId": "JO-15550", + "Customers.customerName": "Customer 24", }, Object { - "Customers.customerId": "SB-20185", - "Customers.customerName": "Customer 37", + "Customers.customerId": "JS-16030", + "Customers.customerName": "Customer 25", }, Object { - "Customers.customerId": "TB-21175", - "Customers.customerName": "Customer 39", + "Customers.customerId": "JW-15220", + "Customers.customerName": "Customer 26", }, Object { - "Customers.customerId": "TS-21205", - "Customers.customerName": "Customer 40", + "Customers.customerId": "LC-17050", + "Customers.customerName": "Customer 29", + }, + Object { + "Customers.customerId": "MG-17650", + "Customers.customerName": "Customer 32", + }, + Object { + "Customers.customerId": "MM-18280", + "Customers.customerName": "Customer 34", + }, + Object { + "Customers.customerId": "NP-18670", + "Customers.customerName": "Customer 35", + }, + Object { + "Customers.customerId": "SS-20140", + "Customers.customerName": "Customer 38", + }, + Object { + "Customers.customerId": "WB-21850", + "Customers.customerName": "Customer 41", }, ] `; -exports[`Queries with the @cubejs-backend/bigquery-driver filtering Customers: notEndsWith filter + dimensions, second 1`] = `Array []`; - -exports[`Queries with the @cubejs-backend/bigquery-driver filtering Customers: notEndsWith filter + dimensions, third 1`] = ` +exports[`Queries with the @cubejs-backend/bigquery-driver filtering Customers: endsWith filter + dimensions, second 1`] = ` Array [ Object { "Customers.customerId": "AH-10465", @@ -4908,27 +4911,21 @@ Array [ ] `; -exports[`Queries with the @cubejs-backend/bigquery-driver filtering Customers: notStartsWith + dimensions, first 1`] = ` +exports[`Queries with the @cubejs-backend/bigquery-driver filtering Customers: endsWith filter + dimensions, third 1`] = `Array []`; + +exports[`Queries with the @cubejs-backend/bigquery-driver filtering Customers: notEndsWith filter + dimensions, first 1`] = ` Array [ Object { - "Customers.customerId": "BB-11545", - "Customers.customerName": "Customer 5", - }, - Object { - "Customers.customerId": "BF-11020", - "Customers.customerName": "Customer 6", - }, - Object { - "Customers.customerId": "BF-11170", - "Customers.customerName": "Customer 7", + "Customers.customerId": "AH-10465", + "Customers.customerName": "Customer 1", }, Object { - "Customers.customerId": "BM-11650", - "Customers.customerName": "Customer 8", + "Customers.customerId": "AS-10225", + "Customers.customerName": "Customer 3", }, Object { - "Customers.customerId": "BS-11380", - "Customers.customerName": "Customer 9", + "Customers.customerId": "BB-11545", + "Customers.customerName": "Customer 5", }, Object { "Customers.customerId": "BS-11755", @@ -4942,10 +4939,6 @@ Array [ "Customers.customerId": "CC-12475", "Customers.customerName": "Customer 12", }, - Object { - "Customers.customerId": "CD-12280", - "Customers.customerName": "Customer 13", - }, Object { "Customers.customerId": "CS-12355", "Customers.customerName": "Customer 14", @@ -4954,50 +4947,10 @@ Array [ "Customers.customerId": "DB-13405", "Customers.customerName": "Customer 15", }, - Object { - "Customers.customerId": "DG-13300", - "Customers.customerName": "Customer 16", - }, - Object { - "Customers.customerId": "DW-13480", - "Customers.customerName": "Customer 17", - }, - Object { - "Customers.customerId": "EM-14140", - "Customers.customerName": "Customer 18", - }, Object { "Customers.customerId": "GA-14725", "Customers.customerName": "Customer 19", }, - Object { - "Customers.customerId": "GZ-14470", - "Customers.customerName": "Customer 20", - }, - Object { - "Customers.customerId": "HH-15010", - "Customers.customerName": "Customer 21", - }, - Object { - "Customers.customerId": "HK-14890", - "Customers.customerName": "Customer 22", - }, - Object { - "Customers.customerId": "JH-15430", - "Customers.customerName": "Customer 23", - }, - Object { - "Customers.customerId": "JO-15550", - "Customers.customerName": "Customer 24", - }, - Object { - "Customers.customerId": "JS-16030", - "Customers.customerName": "Customer 25", - }, - Object { - "Customers.customerId": "JW-15220", - "Customers.customerName": "Customer 26", - }, Object { "Customers.customerId": "KL-16555", "Customers.customerName": "Customer 27", @@ -5006,10 +4959,6 @@ Array [ "Customers.customerId": "KN-16705", "Customers.customerName": "Customer 28", }, - Object { - "Customers.customerId": "LC-17050", - "Customers.customerName": "Customer 29", - }, Object { "Customers.customerId": "LR-16915", "Customers.customerName": "Customer 30", @@ -5018,22 +4967,10 @@ Array [ "Customers.customerId": "MC-17605", "Customers.customerName": "Customer 31", }, - Object { - "Customers.customerId": "MG-17650", - "Customers.customerName": "Customer 32", - }, Object { "Customers.customerId": "ML-17755", "Customers.customerName": "Customer 33", }, - Object { - "Customers.customerId": "MM-18280", - "Customers.customerName": "Customer 34", - }, - Object { - "Customers.customerId": "NP-18670", - "Customers.customerName": "Customer 35", - }, Object { "Customers.customerId": "PF-19165", "Customers.customerName": "Customer 36", @@ -5042,10 +4979,6 @@ Array [ "Customers.customerId": "SB-20185", "Customers.customerName": "Customer 37", }, - Object { - "Customers.customerId": "SS-20140", - "Customers.customerName": "Customer 38", - }, Object { "Customers.customerId": "TB-21175", "Customers.customerName": "Customer 39", @@ -5054,15 +4987,53 @@ Array [ "Customers.customerId": "TS-21205", "Customers.customerName": "Customer 40", }, - Object { - "Customers.customerId": "WB-21850", - "Customers.customerName": "Customer 41", - }, ] `; -exports[`Queries with the @cubejs-backend/bigquery-driver filtering Customers: notStartsWith + dimensions, second 1`] = ` +exports[`Queries with the @cubejs-backend/bigquery-driver filtering Customers: notEndsWith filter + dimensions, second 1`] = `Array []`; + +exports[`Queries with the @cubejs-backend/bigquery-driver filtering Customers: notEndsWith filter + dimensions, third 1`] = ` Array [ + Object { + "Customers.customerId": "AH-10465", + "Customers.customerName": "Customer 1", + }, + Object { + "Customers.customerId": "AJ-10780", + "Customers.customerName": "Customer 2", + }, + Object { + "Customers.customerId": "AS-10225", + "Customers.customerName": "Customer 3", + }, + Object { + "Customers.customerId": "AW-10840", + "Customers.customerName": "Customer 4", + }, + Object { + "Customers.customerId": "BB-11545", + "Customers.customerName": "Customer 5", + }, + Object { + "Customers.customerId": "BF-11020", + "Customers.customerName": "Customer 6", + }, + Object { + "Customers.customerId": "BF-11170", + "Customers.customerName": "Customer 7", + }, + Object { + "Customers.customerId": "BM-11650", + "Customers.customerName": "Customer 8", + }, + Object { + "Customers.customerId": "BS-11380", + "Customers.customerName": "Customer 9", + }, + Object { + "Customers.customerId": "BS-11755", + "Customers.customerName": "Customer 10", + }, Object { "Customers.customerId": "CA-12775", "Customers.customerName": "Customer 11", @@ -5190,24 +5161,8 @@ Array [ ] `; -exports[`Queries with the @cubejs-backend/bigquery-driver filtering Customers: notStartsWith + dimensions, third 1`] = ` +exports[`Queries with the @cubejs-backend/bigquery-driver filtering Customers: notStartsWith + dimensions, first 1`] = ` Array [ - Object { - "Customers.customerId": "AH-10465", - "Customers.customerName": "Customer 1", - }, - Object { - "Customers.customerId": "AJ-10780", - "Customers.customerName": "Customer 2", - }, - Object { - "Customers.customerId": "AS-10225", - "Customers.customerName": "Customer 3", - }, - Object { - "Customers.customerId": "AW-10840", - "Customers.customerName": "Customer 4", - }, Object { "Customers.customerId": "BB-11545", "Customers.customerName": "Customer 5", @@ -5359,28 +5314,136 @@ Array [ ] `; -exports[`Queries with the @cubejs-backend/bigquery-driver filtering Customers: startsWith + dimensions, first 1`] = ` +exports[`Queries with the @cubejs-backend/bigquery-driver filtering Customers: notStartsWith + dimensions, second 1`] = ` Array [ Object { - "Customers.customerId": "AH-10465", - "Customers.customerName": "Customer 1", + "Customers.customerId": "CA-12775", + "Customers.customerName": "Customer 11", }, Object { - "Customers.customerId": "AJ-10780", - "Customers.customerName": "Customer 2", + "Customers.customerId": "CC-12475", + "Customers.customerName": "Customer 12", }, Object { - "Customers.customerId": "AS-10225", - "Customers.customerName": "Customer 3", + "Customers.customerId": "CD-12280", + "Customers.customerName": "Customer 13", }, Object { - "Customers.customerId": "AW-10840", - "Customers.customerName": "Customer 4", + "Customers.customerId": "CS-12355", + "Customers.customerName": "Customer 14", + }, + Object { + "Customers.customerId": "DB-13405", + "Customers.customerName": "Customer 15", + }, + Object { + "Customers.customerId": "DG-13300", + "Customers.customerName": "Customer 16", + }, + Object { + "Customers.customerId": "DW-13480", + "Customers.customerName": "Customer 17", + }, + Object { + "Customers.customerId": "EM-14140", + "Customers.customerName": "Customer 18", + }, + Object { + "Customers.customerId": "GA-14725", + "Customers.customerName": "Customer 19", + }, + Object { + "Customers.customerId": "GZ-14470", + "Customers.customerName": "Customer 20", + }, + Object { + "Customers.customerId": "HH-15010", + "Customers.customerName": "Customer 21", + }, + Object { + "Customers.customerId": "HK-14890", + "Customers.customerName": "Customer 22", + }, + Object { + "Customers.customerId": "JH-15430", + "Customers.customerName": "Customer 23", + }, + Object { + "Customers.customerId": "JO-15550", + "Customers.customerName": "Customer 24", + }, + Object { + "Customers.customerId": "JS-16030", + "Customers.customerName": "Customer 25", + }, + Object { + "Customers.customerId": "JW-15220", + "Customers.customerName": "Customer 26", + }, + Object { + "Customers.customerId": "KL-16555", + "Customers.customerName": "Customer 27", + }, + Object { + "Customers.customerId": "KN-16705", + "Customers.customerName": "Customer 28", + }, + Object { + "Customers.customerId": "LC-17050", + "Customers.customerName": "Customer 29", + }, + Object { + "Customers.customerId": "LR-16915", + "Customers.customerName": "Customer 30", + }, + Object { + "Customers.customerId": "MC-17605", + "Customers.customerName": "Customer 31", + }, + Object { + "Customers.customerId": "MG-17650", + "Customers.customerName": "Customer 32", + }, + Object { + "Customers.customerId": "ML-17755", + "Customers.customerName": "Customer 33", + }, + Object { + "Customers.customerId": "MM-18280", + "Customers.customerName": "Customer 34", + }, + Object { + "Customers.customerId": "NP-18670", + "Customers.customerName": "Customer 35", + }, + Object { + "Customers.customerId": "PF-19165", + "Customers.customerName": "Customer 36", + }, + Object { + "Customers.customerId": "SB-20185", + "Customers.customerName": "Customer 37", + }, + Object { + "Customers.customerId": "SS-20140", + "Customers.customerName": "Customer 38", + }, + Object { + "Customers.customerId": "TB-21175", + "Customers.customerName": "Customer 39", + }, + Object { + "Customers.customerId": "TS-21205", + "Customers.customerName": "Customer 40", + }, + Object { + "Customers.customerId": "WB-21850", + "Customers.customerName": "Customer 41", }, ] `; -exports[`Queries with the @cubejs-backend/bigquery-driver filtering Customers: startsWith + dimensions, second 1`] = ` +exports[`Queries with the @cubejs-backend/bigquery-driver filtering Customers: notStartsWith + dimensions, third 1`] = ` Array [ Object { "Customers.customerId": "AH-10465", @@ -5422,209 +5485,237 @@ Array [ "Customers.customerId": "BS-11755", "Customers.customerName": "Customer 10", }, -] -`; - -exports[`Queries with the @cubejs-backend/bigquery-driver filtering Customers: startsWith + dimensions, third 1`] = `Array []`; - -exports[`Queries with the @cubejs-backend/bigquery-driver filtering ECommerce: contains dimensions, first 1`] = ` -Array [ Object { - "ECommerce.category": "Furniture", - "ECommerce.city": "Detroit", - "ECommerce.customerId": "MC-17605", - "ECommerce.customerName": "Customer 31", - "ECommerce.discount": 0, - "ECommerce.orderDate": "2020-01-23T00:00:00.000", - "ECommerce.orderId": "CA-2017-145142", - "ECommerce.productName": "Balt Solid Wood Rectangular Table", - "ECommerce.profit": 21.098, - "ECommerce.quantity": 2, - "ECommerce.rowId": 523, - "ECommerce.sales": 210.98, - "ECommerce.subCategory": "Tables", + "Customers.customerId": "CA-12775", + "Customers.customerName": "Customer 11", }, Object { - "ECommerce.category": "Furniture", - "ECommerce.city": "San Francisco", - "ECommerce.customerId": "HH-15010", - "ECommerce.customerName": "Customer 21", - "ECommerce.discount": 0.2, - "ECommerce.orderDate": "2020-10-19T00:00:00.000", - "ECommerce.orderId": "CA-2017-131492", - "ECommerce.productName": "Anderson Hickey Conga Table Tops & Accessories", - "ECommerce.profit": -3.3506, - "ECommerce.quantity": 2, - "ECommerce.rowId": 3060, - "ECommerce.sales": 24.368, - "ECommerce.subCategory": "Tables", + "Customers.customerId": "CC-12475", + "Customers.customerName": "Customer 12", }, -] -`; - -exports[`Queries with the @cubejs-backend/bigquery-driver filtering ECommerce: contains dimensions, second 1`] = ` -Array [ Object { - "ECommerce.category": "Furniture", - "ECommerce.city": "Detroit", - "ECommerce.customerId": "MC-17605", - "ECommerce.customerName": "Customer 31", - "ECommerce.discount": 0, - "ECommerce.orderDate": "2020-01-23T00:00:00.000", - "ECommerce.orderId": "CA-2017-145142", - "ECommerce.productName": "Balt Solid Wood Rectangular Table", - "ECommerce.profit": 21.098, - "ECommerce.quantity": 2, - "ECommerce.rowId": 523, - "ECommerce.sales": 210.98, - "ECommerce.subCategory": "Tables", + "Customers.customerId": "CD-12280", + "Customers.customerName": "Customer 13", }, Object { - "ECommerce.category": "Furniture", - "ECommerce.city": "Lorain", - "ECommerce.customerId": "GA-14725", - "ECommerce.customerName": "Customer 19", - "ECommerce.discount": 0.2, - "ECommerce.orderDate": "2020-01-01T00:00:00.000", - "ECommerce.orderId": "CA-2017-107503", - "ECommerce.productName": "Linden 10 Round Wall Clock, Black", - "ECommerce.profit": 8.5568, - "ECommerce.quantity": 4, - "ECommerce.rowId": 849, - "ECommerce.sales": 48.896, - "ECommerce.subCategory": "Furnishings", + "Customers.customerId": "CS-12355", + "Customers.customerName": "Customer 14", }, Object { - "ECommerce.category": "Furniture", - "ECommerce.city": "Vancouver", - "ECommerce.customerId": "JW-15220", - "ECommerce.customerName": "Customer 26", - "ECommerce.discount": 0, - "ECommerce.orderDate": "2020-10-30T00:00:00.000", - "ECommerce.orderId": "CA-2017-139661", - "ECommerce.productName": "Magna Visual Magnetic Picture Hangers", - "ECommerce.profit": 3.6632, - "ECommerce.quantity": 2, - "ECommerce.rowId": 1494, - "ECommerce.sales": 9.64, - "ECommerce.subCategory": "Furnishings", + "Customers.customerId": "DB-13405", + "Customers.customerName": "Customer 15", }, Object { - "ECommerce.category": "Furniture", - "ECommerce.city": "San Francisco", - "ECommerce.customerId": "HH-15010", - "ECommerce.customerName": "Customer 21", - "ECommerce.discount": 0, - "ECommerce.orderDate": "2020-10-19T00:00:00.000", - "ECommerce.orderId": "CA-2017-131492", - "ECommerce.productName": "Linden 10 Round Wall Clock, Black", - "ECommerce.profit": 10.3904, - "ECommerce.quantity": 2, - "ECommerce.rowId": 3059, - "ECommerce.sales": 30.56, - "ECommerce.subCategory": "Furnishings", + "Customers.customerId": "DG-13300", + "Customers.customerName": "Customer 16", }, Object { - "ECommerce.category": "Furniture", - "ECommerce.city": "San Francisco", - "ECommerce.customerId": "HH-15010", - "ECommerce.customerName": "Customer 21", - "ECommerce.discount": 0.2, - "ECommerce.orderDate": "2020-10-19T00:00:00.000", - "ECommerce.orderId": "CA-2017-131492", - "ECommerce.productName": "Anderson Hickey Conga Table Tops & Accessories", - "ECommerce.profit": -3.3506, - "ECommerce.quantity": 2, - "ECommerce.rowId": 3060, - "ECommerce.sales": 24.368, - "ECommerce.subCategory": "Tables", + "Customers.customerId": "DW-13480", + "Customers.customerName": "Customer 17", }, Object { - "ECommerce.category": "Furniture", - "ECommerce.city": "Marion", - "ECommerce.customerId": "MG-17650", - "ECommerce.customerName": "Customer 32", - "ECommerce.discount": 0.2, - "ECommerce.orderDate": "2020-12-01T00:00:00.000", - "ECommerce.orderId": "CA-2017-145660", - "ECommerce.productName": "Magna Visual Magnetic Picture Hangers", - "ECommerce.profit": 1.7352, - "ECommerce.quantity": 2, - "ECommerce.rowId": 6205, - "ECommerce.sales": 7.712, - "ECommerce.subCategory": "Furnishings", + "Customers.customerId": "EM-14140", + "Customers.customerName": "Customer 18", }, Object { - "ECommerce.category": "Furniture", - "ECommerce.city": "Philadelphia", - "ECommerce.customerId": "BS-11755", - "ECommerce.customerName": "Customer 10", - "ECommerce.discount": 0.2, - "ECommerce.orderDate": "2020-04-10T00:00:00.000", - "ECommerce.orderId": "CA-2017-135069", - "ECommerce.productName": "Linden 10 Round Wall Clock, Black", - "ECommerce.profit": 6.4176, - "ECommerce.quantity": 3, - "ECommerce.rowId": 7425, - "ECommerce.sales": 36.672, - "ECommerce.subCategory": "Furnishings", + "Customers.customerId": "GA-14725", + "Customers.customerName": "Customer 19", }, Object { - "ECommerce.category": "Furniture", - "ECommerce.city": "Dallas", - "ECommerce.customerId": "LC-17050", - "ECommerce.customerName": "Customer 29", - "ECommerce.discount": 0.6, - "ECommerce.orderDate": "2020-11-06T00:00:00.000", - "ECommerce.orderId": "US-2017-119319", - "ECommerce.productName": "Linden 10 Round Wall Clock, Black", - "ECommerce.profit": -19.864, - "ECommerce.quantity": 5, - "ECommerce.rowId": 8621, - "ECommerce.sales": 30.56, - "ECommerce.subCategory": "Furnishings", + "Customers.customerId": "GZ-14470", + "Customers.customerName": "Customer 20", + }, + Object { + "Customers.customerId": "HH-15010", + "Customers.customerName": "Customer 21", + }, + Object { + "Customers.customerId": "HK-14890", + "Customers.customerName": "Customer 22", + }, + Object { + "Customers.customerId": "JH-15430", + "Customers.customerName": "Customer 23", + }, + Object { + "Customers.customerId": "JO-15550", + "Customers.customerName": "Customer 24", + }, + Object { + "Customers.customerId": "JS-16030", + "Customers.customerName": "Customer 25", + }, + Object { + "Customers.customerId": "JW-15220", + "Customers.customerName": "Customer 26", + }, + Object { + "Customers.customerId": "KL-16555", + "Customers.customerName": "Customer 27", + }, + Object { + "Customers.customerId": "KN-16705", + "Customers.customerName": "Customer 28", + }, + Object { + "Customers.customerId": "LC-17050", + "Customers.customerName": "Customer 29", + }, + Object { + "Customers.customerId": "LR-16915", + "Customers.customerName": "Customer 30", + }, + Object { + "Customers.customerId": "MC-17605", + "Customers.customerName": "Customer 31", + }, + Object { + "Customers.customerId": "MG-17650", + "Customers.customerName": "Customer 32", + }, + Object { + "Customers.customerId": "ML-17755", + "Customers.customerName": "Customer 33", + }, + Object { + "Customers.customerId": "MM-18280", + "Customers.customerName": "Customer 34", + }, + Object { + "Customers.customerId": "NP-18670", + "Customers.customerName": "Customer 35", + }, + Object { + "Customers.customerId": "PF-19165", + "Customers.customerName": "Customer 36", + }, + Object { + "Customers.customerId": "SB-20185", + "Customers.customerName": "Customer 37", + }, + Object { + "Customers.customerId": "SS-20140", + "Customers.customerName": "Customer 38", + }, + Object { + "Customers.customerId": "TB-21175", + "Customers.customerName": "Customer 39", + }, + Object { + "Customers.customerId": "TS-21205", + "Customers.customerName": "Customer 40", + }, + Object { + "Customers.customerId": "WB-21850", + "Customers.customerName": "Customer 41", }, ] `; -exports[`Queries with the @cubejs-backend/bigquery-driver filtering ECommerce: contains dimensions, third 1`] = `Array []`; +exports[`Queries with the @cubejs-backend/bigquery-driver filtering Customers: startsWith + dimensions, first 1`] = ` +Array [ + Object { + "Customers.customerId": "AH-10465", + "Customers.customerName": "Customer 1", + }, + Object { + "Customers.customerId": "AJ-10780", + "Customers.customerName": "Customer 2", + }, + Object { + "Customers.customerId": "AS-10225", + "Customers.customerName": "Customer 3", + }, + Object { + "Customers.customerId": "AW-10840", + "Customers.customerName": "Customer 4", + }, +] +`; -exports[`Queries with the @cubejs-backend/bigquery-driver filtering ECommerce: endsWith + dimensions, first 1`] = ` +exports[`Queries with the @cubejs-backend/bigquery-driver filtering Customers: startsWith + dimensions, second 1`] = ` +Array [ + Object { + "Customers.customerId": "AH-10465", + "Customers.customerName": "Customer 1", + }, + Object { + "Customers.customerId": "AJ-10780", + "Customers.customerName": "Customer 2", + }, + Object { + "Customers.customerId": "AS-10225", + "Customers.customerName": "Customer 3", + }, + Object { + "Customers.customerId": "AW-10840", + "Customers.customerName": "Customer 4", + }, + Object { + "Customers.customerId": "BB-11545", + "Customers.customerName": "Customer 5", + }, + Object { + "Customers.customerId": "BF-11020", + "Customers.customerName": "Customer 6", + }, + Object { + "Customers.customerId": "BF-11170", + "Customers.customerName": "Customer 7", + }, + Object { + "Customers.customerId": "BM-11650", + "Customers.customerName": "Customer 8", + }, + Object { + "Customers.customerId": "BS-11380", + "Customers.customerName": "Customer 9", + }, + Object { + "Customers.customerId": "BS-11755", + "Customers.customerName": "Customer 10", + }, +] +`; + +exports[`Queries with the @cubejs-backend/bigquery-driver filtering Customers: startsWith + dimensions, third 1`] = `Array []`; + +exports[`Queries with the @cubejs-backend/bigquery-driver filtering ECommerce: contains dimensions, first 1`] = ` Array [ Object { "ECommerce.category": "Furniture", - "ECommerce.city": "Marion", - "ECommerce.customerId": "MG-17650", - "ECommerce.customerName": "Customer 32", - "ECommerce.discount": 0.2, - "ECommerce.orderDate": "2020-12-01T00:00:00.000", - "ECommerce.orderId": "CA-2017-145660", - "ECommerce.productName": "Magna Visual Magnetic Picture Hangers", - "ECommerce.profit": 1.7352, + "ECommerce.city": "Detroit", + "ECommerce.customerId": "MC-17605", + "ECommerce.customerName": "Customer 31", + "ECommerce.discount": 0, + "ECommerce.orderDate": "2020-01-23T00:00:00.000", + "ECommerce.orderId": "CA-2017-145142", + "ECommerce.productName": "Balt Solid Wood Rectangular Table", + "ECommerce.profit": 21.098, "ECommerce.quantity": 2, - "ECommerce.rowId": 6205, - "ECommerce.sales": 7.712, - "ECommerce.subCategory": "Furnishings", + "ECommerce.rowId": 523, + "ECommerce.sales": 210.98, + "ECommerce.subCategory": "Tables", }, Object { - "ECommerce.category": "Technology", - "ECommerce.city": "Columbus", - "ECommerce.customerId": "JH-15430", - "ECommerce.customerName": "Customer 23", - "ECommerce.discount": 0.5, - "ECommerce.orderDate": "2020-12-25T00:00:00.000", - "ECommerce.orderId": "CA-2017-105620", - "ECommerce.productName": "Lexmark 20R1285 X6650 Wireless All-in-One Printer", - "ECommerce.profit": -7.2, + "ECommerce.category": "Furniture", + "ECommerce.city": "San Francisco", + "ECommerce.customerId": "HH-15010", + "ECommerce.customerName": "Customer 21", + "ECommerce.discount": 0.2, + "ECommerce.orderDate": "2020-10-19T00:00:00.000", + "ECommerce.orderId": "CA-2017-131492", + "ECommerce.productName": "Anderson Hickey Conga Table Tops & Accessories", + "ECommerce.profit": -3.3506, "ECommerce.quantity": 2, - "ECommerce.rowId": 8958, - "ECommerce.sales": 120, - "ECommerce.subCategory": "Machines", + "ECommerce.rowId": 3060, + "ECommerce.sales": 24.368, + "ECommerce.subCategory": "Tables", }, ] `; -exports[`Queries with the @cubejs-backend/bigquery-driver filtering ECommerce: endsWith + dimensions, second 1`] = ` +exports[`Queries with the @cubejs-backend/bigquery-driver filtering ECommerce: contains dimensions, second 1`] = ` Array [ Object { "ECommerce.category": "Furniture", @@ -5641,6 +5732,21 @@ Array [ "ECommerce.sales": 210.98, "ECommerce.subCategory": "Tables", }, + Object { + "ECommerce.category": "Furniture", + "ECommerce.city": "Lorain", + "ECommerce.customerId": "GA-14725", + "ECommerce.customerName": "Customer 19", + "ECommerce.discount": 0.2, + "ECommerce.orderDate": "2020-01-01T00:00:00.000", + "ECommerce.orderId": "CA-2017-107503", + "ECommerce.productName": "Linden 10 Round Wall Clock, Black", + "ECommerce.profit": 8.5568, + "ECommerce.quantity": 4, + "ECommerce.rowId": 849, + "ECommerce.sales": 48.896, + "ECommerce.subCategory": "Furnishings", + }, Object { "ECommerce.category": "Furniture", "ECommerce.city": "Vancouver", @@ -5657,22 +5763,169 @@ Array [ "ECommerce.subCategory": "Furnishings", }, Object { - "ECommerce.category": "Office Supplies", - "ECommerce.city": "Columbus", - "ECommerce.customerId": "KN-16705", - "ECommerce.customerName": "Customer 28", - "ECommerce.discount": 0.2, - "ECommerce.orderDate": "2020-09-23T00:00:00.000", - "ECommerce.orderId": "CA-2017-138422", - "ECommerce.productName": "Wausau Papers Astrobrights Colored Envelopes", - "ECommerce.profit": 5.2026, - "ECommerce.quantity": 3, - "ECommerce.rowId": 2329, - "ECommerce.sales": 14.352, - "ECommerce.subCategory": "Envelopes", - }, - Object { - "ECommerce.category": "Technology", + "ECommerce.category": "Furniture", + "ECommerce.city": "San Francisco", + "ECommerce.customerId": "HH-15010", + "ECommerce.customerName": "Customer 21", + "ECommerce.discount": 0, + "ECommerce.orderDate": "2020-10-19T00:00:00.000", + "ECommerce.orderId": "CA-2017-131492", + "ECommerce.productName": "Linden 10 Round Wall Clock, Black", + "ECommerce.profit": 10.3904, + "ECommerce.quantity": 2, + "ECommerce.rowId": 3059, + "ECommerce.sales": 30.56, + "ECommerce.subCategory": "Furnishings", + }, + Object { + "ECommerce.category": "Furniture", + "ECommerce.city": "San Francisco", + "ECommerce.customerId": "HH-15010", + "ECommerce.customerName": "Customer 21", + "ECommerce.discount": 0.2, + "ECommerce.orderDate": "2020-10-19T00:00:00.000", + "ECommerce.orderId": "CA-2017-131492", + "ECommerce.productName": "Anderson Hickey Conga Table Tops & Accessories", + "ECommerce.profit": -3.3506, + "ECommerce.quantity": 2, + "ECommerce.rowId": 3060, + "ECommerce.sales": 24.368, + "ECommerce.subCategory": "Tables", + }, + Object { + "ECommerce.category": "Furniture", + "ECommerce.city": "Marion", + "ECommerce.customerId": "MG-17650", + "ECommerce.customerName": "Customer 32", + "ECommerce.discount": 0.2, + "ECommerce.orderDate": "2020-12-01T00:00:00.000", + "ECommerce.orderId": "CA-2017-145660", + "ECommerce.productName": "Magna Visual Magnetic Picture Hangers", + "ECommerce.profit": 1.7352, + "ECommerce.quantity": 2, + "ECommerce.rowId": 6205, + "ECommerce.sales": 7.712, + "ECommerce.subCategory": "Furnishings", + }, + Object { + "ECommerce.category": "Furniture", + "ECommerce.city": "Philadelphia", + "ECommerce.customerId": "BS-11755", + "ECommerce.customerName": "Customer 10", + "ECommerce.discount": 0.2, + "ECommerce.orderDate": "2020-04-10T00:00:00.000", + "ECommerce.orderId": "CA-2017-135069", + "ECommerce.productName": "Linden 10 Round Wall Clock, Black", + "ECommerce.profit": 6.4176, + "ECommerce.quantity": 3, + "ECommerce.rowId": 7425, + "ECommerce.sales": 36.672, + "ECommerce.subCategory": "Furnishings", + }, + Object { + "ECommerce.category": "Furniture", + "ECommerce.city": "Dallas", + "ECommerce.customerId": "LC-17050", + "ECommerce.customerName": "Customer 29", + "ECommerce.discount": 0.6, + "ECommerce.orderDate": "2020-11-06T00:00:00.000", + "ECommerce.orderId": "US-2017-119319", + "ECommerce.productName": "Linden 10 Round Wall Clock, Black", + "ECommerce.profit": -19.864, + "ECommerce.quantity": 5, + "ECommerce.rowId": 8621, + "ECommerce.sales": 30.56, + "ECommerce.subCategory": "Furnishings", + }, +] +`; + +exports[`Queries with the @cubejs-backend/bigquery-driver filtering ECommerce: contains dimensions, third 1`] = `Array []`; + +exports[`Queries with the @cubejs-backend/bigquery-driver filtering ECommerce: endsWith + dimensions, first 1`] = ` +Array [ + Object { + "ECommerce.category": "Furniture", + "ECommerce.city": "Marion", + "ECommerce.customerId": "MG-17650", + "ECommerce.customerName": "Customer 32", + "ECommerce.discount": 0.2, + "ECommerce.orderDate": "2020-12-01T00:00:00.000", + "ECommerce.orderId": "CA-2017-145660", + "ECommerce.productName": "Magna Visual Magnetic Picture Hangers", + "ECommerce.profit": 1.7352, + "ECommerce.quantity": 2, + "ECommerce.rowId": 6205, + "ECommerce.sales": 7.712, + "ECommerce.subCategory": "Furnishings", + }, + Object { + "ECommerce.category": "Technology", + "ECommerce.city": "Columbus", + "ECommerce.customerId": "JH-15430", + "ECommerce.customerName": "Customer 23", + "ECommerce.discount": 0.5, + "ECommerce.orderDate": "2020-12-25T00:00:00.000", + "ECommerce.orderId": "CA-2017-105620", + "ECommerce.productName": "Lexmark 20R1285 X6650 Wireless All-in-One Printer", + "ECommerce.profit": -7.2, + "ECommerce.quantity": 2, + "ECommerce.rowId": 8958, + "ECommerce.sales": 120, + "ECommerce.subCategory": "Machines", + }, +] +`; + +exports[`Queries with the @cubejs-backend/bigquery-driver filtering ECommerce: endsWith + dimensions, second 1`] = ` +Array [ + Object { + "ECommerce.category": "Furniture", + "ECommerce.city": "Detroit", + "ECommerce.customerId": "MC-17605", + "ECommerce.customerName": "Customer 31", + "ECommerce.discount": 0, + "ECommerce.orderDate": "2020-01-23T00:00:00.000", + "ECommerce.orderId": "CA-2017-145142", + "ECommerce.productName": "Balt Solid Wood Rectangular Table", + "ECommerce.profit": 21.098, + "ECommerce.quantity": 2, + "ECommerce.rowId": 523, + "ECommerce.sales": 210.98, + "ECommerce.subCategory": "Tables", + }, + Object { + "ECommerce.category": "Furniture", + "ECommerce.city": "Vancouver", + "ECommerce.customerId": "JW-15220", + "ECommerce.customerName": "Customer 26", + "ECommerce.discount": 0, + "ECommerce.orderDate": "2020-10-30T00:00:00.000", + "ECommerce.orderId": "CA-2017-139661", + "ECommerce.productName": "Magna Visual Magnetic Picture Hangers", + "ECommerce.profit": 3.6632, + "ECommerce.quantity": 2, + "ECommerce.rowId": 1494, + "ECommerce.sales": 9.64, + "ECommerce.subCategory": "Furnishings", + }, + Object { + "ECommerce.category": "Office Supplies", + "ECommerce.city": "Columbus", + "ECommerce.customerId": "KN-16705", + "ECommerce.customerName": "Customer 28", + "ECommerce.discount": 0.2, + "ECommerce.orderDate": "2020-09-23T00:00:00.000", + "ECommerce.orderId": "CA-2017-138422", + "ECommerce.productName": "Wausau Papers Astrobrights Colored Envelopes", + "ECommerce.profit": 5.2026, + "ECommerce.quantity": 3, + "ECommerce.rowId": 2329, + "ECommerce.sales": 14.352, + "ECommerce.subCategory": "Envelopes", + }, + Object { + "ECommerce.category": "Technology", "ECommerce.city": "Columbus", "ECommerce.customerId": "DG-13300", "ECommerce.customerName": "Customer 16", @@ -6029,636 +6282,308 @@ Array [ "ECommerce.subCategory": "Copiers", }, Object { - "ECommerce.category": "Office Supplies", - "ECommerce.city": "Bowling", - "ECommerce.customerId": "BS-11380", - "ECommerce.customerName": "Customer 9", - "ECommerce.discount": 0.2, - "ECommerce.orderDate": "2020-11-16T00:00:00.000", - "ECommerce.orderId": "CA-2017-160633", - "ECommerce.productName": "Panasonic KP-380BK Classic Electric Pencil Sharpener", - "ECommerce.profit": 5.397, - "ECommerce.quantity": 3, - "ECommerce.rowId": 9619, - "ECommerce.sales": 86.352, - "ECommerce.subCategory": "Art", - }, -] -`; - -exports[`Queries with the @cubejs-backend/bigquery-driver filtering ECommerce: startsWith + dimensions, third 1`] = `Array []`; - -exports[`Queries with the @cubejs-backend/bigquery-driver filtering Products: contains + dimensions + order, first 1`] = ` -Array [ - Object { - "Products.category": "Furniture", - "Products.productName": "Anderson Hickey Conga Table Tops & Accessories", - "Products.subCategory": "Tables", - }, - Object { - "Products.category": "Furniture", - "Products.productName": "Balt Solid Wood Rectangular Table", - "Products.subCategory": "Tables", - }, -] -`; - -exports[`Queries with the @cubejs-backend/bigquery-driver filtering Products: contains + dimensions + order, second 1`] = ` -Array [ - Object { - "Products.category": "Furniture", - "Products.productName": "Linden 10 Round Wall Clock, Black", - "Products.subCategory": "Furnishings", - }, - Object { - "Products.category": "Furniture", - "Products.productName": "Magna Visual Magnetic Picture Hangers", - "Products.subCategory": "Furnishings", - }, - Object { - "Products.category": "Furniture", - "Products.productName": "Anderson Hickey Conga Table Tops & Accessories", - "Products.subCategory": "Tables", - }, - Object { - "Products.category": "Furniture", - "Products.productName": "Balt Solid Wood Rectangular Table", - "Products.subCategory": "Tables", - }, -] -`; - -exports[`Queries with the @cubejs-backend/bigquery-driver filtering Products: contains + dimensions + order, third 1`] = `Array []`; - -exports[`Queries with the @cubejs-backend/bigquery-driver filtering Products: contains with special chars + dimensions 1`] = ` -Array [ - Object { - "Products.productName": "Logitech di_Novo Edge Keyboard", - }, -] -`; - -exports[`Queries with the @cubejs-backend/bigquery-driver filtering Products: endsWith filter + dimensions + order, first 1`] = ` -Array [ - Object { - "Products.category": "Furniture", - "Products.productName": "DMI Eclipse Executive Suite Bookcases", - "Products.subCategory": "Bookcases", - }, - Object { - "Products.category": "Furniture", - "Products.productName": "Global Adaptabilites Bookcase, Cherry/Storm Gray Finish", - "Products.subCategory": "Bookcases", - }, - Object { - "Products.category": "Furniture", - "Products.productName": "Anderson Hickey Conga Table Tops & Accessories", - "Products.subCategory": "Tables", - }, - Object { - "Products.category": "Furniture", - "Products.productName": "Balt Solid Wood Rectangular Table", - "Products.subCategory": "Tables", - }, - Object { - "Products.category": "Office Supplies", - "Products.productName": "Tyvek Side-Opening Peel & Seel Expanding Envelopes", - "Products.subCategory": "Envelopes", - }, - Object { - "Products.category": "Office Supplies", - "Products.productName": "Wausau Papers Astrobrights Colored Envelopes", - "Products.subCategory": "Envelopes", - }, - Object { - "Products.category": "Technology", - "Products.productName": "Kingston Digital DataTraveler 16GB USB 2.0", - "Products.subCategory": "Accessories", - }, - Object { - "Products.category": "Technology", - "Products.productName": "Kingston Digital DataTraveler 16GB USB 2.1", - "Products.subCategory": "Accessories", - }, - Object { - "Products.category": "Technology", - "Products.productName": "Kingston Digital DataTraveler 16GB USB 2.2", - "Products.subCategory": "Accessories", - }, - Object { - "Products.category": "Technology", - "Products.productName": "Logitech di_Novo Edge Keyboard", - "Products.subCategory": "Accessories", - }, - Object { - "Products.category": "Technology", - "Products.productName": "Lexmark 20R1285 X6650 Wireless All-in-One Printer", - "Products.subCategory": "Machines", - }, - Object { - "Products.category": "Technology", - "Products.productName": "Okidata C610n Printer", - "Products.subCategory": "Machines", - }, - Object { - "Products.category": "Technology", - "Products.productName": "Google Nexus 5", - "Products.subCategory": "Phones", - }, - Object { - "Products.category": "Technology", - "Products.productName": "Google Nexus 6", - "Products.subCategory": "Phones", - }, - Object { - "Products.category": "Technology", - "Products.productName": "Google Nexus 7", - "Products.subCategory": "Phones", - }, - Object { - "Products.category": "Technology", - "Products.productName": "HTC One", - "Products.subCategory": "Phones", - }, -] -`; - -exports[`Queries with the @cubejs-backend/bigquery-driver filtering Products: endsWith filter + dimensions + order, second 1`] = ` -Array [ - Object { - "Products.category": "Furniture", - "Products.productName": "DMI Eclipse Executive Suite Bookcases", - "Products.subCategory": "Bookcases", - }, - Object { - "Products.category": "Furniture", - "Products.productName": "Global Adaptabilites Bookcase, Cherry/Storm Gray Finish", - "Products.subCategory": "Bookcases", - }, - Object { - "Products.category": "Furniture", - "Products.productName": "Linden 10 Round Wall Clock, Black", - "Products.subCategory": "Furnishings", - }, - Object { - "Products.category": "Furniture", - "Products.productName": "Magna Visual Magnetic Picture Hangers", - "Products.subCategory": "Furnishings", - }, - Object { - "Products.category": "Furniture", - "Products.productName": "Anderson Hickey Conga Table Tops & Accessories", - "Products.subCategory": "Tables", - }, - Object { - "Products.category": "Furniture", - "Products.productName": "Balt Solid Wood Rectangular Table", - "Products.subCategory": "Tables", - }, - Object { - "Products.category": "Office Supplies", - "Products.productName": "Tyvek Side-Opening Peel & Seel Expanding Envelopes", - "Products.subCategory": "Envelopes", - }, - Object { - "Products.category": "Office Supplies", - "Products.productName": "Wausau Papers Astrobrights Colored Envelopes", - "Products.subCategory": "Envelopes", - }, - Object { - "Products.category": "Technology", - "Products.productName": "Kingston Digital DataTraveler 16GB USB 2.0", - "Products.subCategory": "Accessories", - }, - Object { - "Products.category": "Technology", - "Products.productName": "Kingston Digital DataTraveler 16GB USB 2.1", - "Products.subCategory": "Accessories", - }, - Object { - "Products.category": "Technology", - "Products.productName": "Kingston Digital DataTraveler 16GB USB 2.2", - "Products.subCategory": "Accessories", - }, - Object { - "Products.category": "Technology", - "Products.productName": "Logitech di_Novo Edge Keyboard", - "Products.subCategory": "Accessories", - }, - Object { - "Products.category": "Technology", - "Products.productName": "Lexmark 20R1285 X6650 Wireless All-in-One Printer", - "Products.subCategory": "Machines", - }, - Object { - "Products.category": "Technology", - "Products.productName": "Okidata C610n Printer", - "Products.subCategory": "Machines", - }, - Object { - "Products.category": "Technology", - "Products.productName": "Google Nexus 5", - "Products.subCategory": "Phones", - }, - Object { - "Products.category": "Technology", - "Products.productName": "Google Nexus 6", - "Products.subCategory": "Phones", - }, - Object { - "Products.category": "Technology", - "Products.productName": "Google Nexus 7", - "Products.subCategory": "Phones", - }, - Object { - "Products.category": "Technology", - "Products.productName": "HTC One", - "Products.subCategory": "Phones", - }, -] -`; - -exports[`Queries with the @cubejs-backend/bigquery-driver filtering Products: endsWith filter + dimensions + order, third 1`] = `Array []`; - -exports[`Queries with the @cubejs-backend/bigquery-driver filtering Products: startsWith filter + dimensions + order, first 1`] = ` -Array [ - Object { - "Products.category": "Office Supplies", - "Products.productName": "OIC #2 Pencils, Medium Soft", - "Products.subCategory": "Art", - }, - Object { - "Products.category": "Technology", - "Products.productName": "Okidata C610n Printer", - "Products.subCategory": "Machines", - }, -] -`; - -exports[`Queries with the @cubejs-backend/bigquery-driver filtering Products: startsWith filter + dimensions + order, second 1`] = ` -Array [ - Object { - "Products.category": "Office Supplies", - "Products.productName": "OIC #2 Pencils, Medium Soft", - "Products.subCategory": "Art", - }, - Object { - "Products.category": "Technology", - "Products.productName": "Kingston Digital DataTraveler 16GB USB 2.0", - "Products.subCategory": "Accessories", - }, - Object { - "Products.category": "Technology", - "Products.productName": "Kingston Digital DataTraveler 16GB USB 2.1", - "Products.subCategory": "Accessories", - }, - Object { - "Products.category": "Technology", - "Products.productName": "Kingston Digital DataTraveler 16GB USB 2.2", - "Products.subCategory": "Accessories", - }, - Object { - "Products.category": "Technology", - "Products.productName": "Okidata C610n Printer", - "Products.subCategory": "Machines", - }, -] -`; - -exports[`Queries with the @cubejs-backend/bigquery-driver filtering Products: startsWith filter + dimensions + order, third 1`] = `Array []`; - -exports[`Queries with the @cubejs-backend/bigquery-driver pre-aggregations Customers: running total without time dimension 1`] = ` -Array [ - Object { - "Customers.runningTotal": "41", - }, -] -`; - -exports[`Queries with the @cubejs-backend/bigquery-driver Tesseract: querying BigECommerce with Retail Calendar: totalCountRetailMonthAgo 1`] = ` -Array [ - Object { - "BigECommerce.count": 1, - "BigECommerce.totalCountRetailMonthAgo": 1, - "RetailCalendar.retail_date": "2020-02-01T00:00:00.000", - "RetailCalendar.retail_date.month": "2020-02-01T00:00:00.000", - }, - Object { - "BigECommerce.count": 2, - "BigECommerce.totalCountRetailMonthAgo": 1, - "RetailCalendar.retail_date": "2020-03-01T00:00:00.000", - "RetailCalendar.retail_date.month": "2020-03-01T00:00:00.000", - }, - Object { - "BigECommerce.count": 1, - "BigECommerce.totalCountRetailMonthAgo": 2, - "RetailCalendar.retail_date": "2020-04-01T00:00:00.000", - "RetailCalendar.retail_date.month": "2020-04-01T00:00:00.000", - }, - Object { - "BigECommerce.count": 5, - "BigECommerce.totalCountRetailMonthAgo": 1, - "RetailCalendar.retail_date": "2020-05-01T00:00:00.000", - "RetailCalendar.retail_date.month": "2020-05-01T00:00:00.000", - }, - Object { - "BigECommerce.count": 7, - "BigECommerce.totalCountRetailMonthAgo": 5, - "RetailCalendar.retail_date": "2020-06-01T00:00:00.000", - "RetailCalendar.retail_date.month": "2020-06-01T00:00:00.000", + "ECommerce.category": "Office Supplies", + "ECommerce.city": "Bowling", + "ECommerce.customerId": "BS-11380", + "ECommerce.customerName": "Customer 9", + "ECommerce.discount": 0.2, + "ECommerce.orderDate": "2020-11-16T00:00:00.000", + "ECommerce.orderId": "CA-2017-160633", + "ECommerce.productName": "Panasonic KP-380BK Classic Electric Pencil Sharpener", + "ECommerce.profit": 5.397, + "ECommerce.quantity": 3, + "ECommerce.rowId": 9619, + "ECommerce.sales": 86.352, + "ECommerce.subCategory": "Art", }, +] +`; + +exports[`Queries with the @cubejs-backend/bigquery-driver filtering ECommerce: startsWith + dimensions, third 1`] = `Array []`; + +exports[`Queries with the @cubejs-backend/bigquery-driver filtering Products: contains + dimensions + order, first 1`] = ` +Array [ Object { - "BigECommerce.count": null, - "BigECommerce.totalCountRetailMonthAgo": 7, - "RetailCalendar.retail_date": "2020-07-01T00:00:00.000", - "RetailCalendar.retail_date.month": "2020-07-01T00:00:00.000", + "Products.category": "Furniture", + "Products.productName": "Anderson Hickey Conga Table Tops & Accessories", + "Products.subCategory": "Tables", }, Object { - "BigECommerce.count": 6, - "BigECommerce.totalCountRetailMonthAgo": null, - "RetailCalendar.retail_date": "2020-09-01T00:00:00.000", - "RetailCalendar.retail_date.month": "2020-09-01T00:00:00.000", + "Products.category": "Furniture", + "Products.productName": "Balt Solid Wood Rectangular Table", + "Products.subCategory": "Tables", }, +] +`; + +exports[`Queries with the @cubejs-backend/bigquery-driver filtering Products: contains + dimensions + order, second 1`] = ` +Array [ Object { - "BigECommerce.count": 4, - "BigECommerce.totalCountRetailMonthAgo": 6, - "RetailCalendar.retail_date": "2020-10-01T00:00:00.000", - "RetailCalendar.retail_date.month": "2020-10-01T00:00:00.000", + "Products.category": "Furniture", + "Products.productName": "Linden 10 Round Wall Clock, Black", + "Products.subCategory": "Furnishings", }, Object { - "BigECommerce.count": 9, - "BigECommerce.totalCountRetailMonthAgo": 5, - "RetailCalendar.retail_date": "2020-11-01T00:00:00.000", - "RetailCalendar.retail_date.month": "2020-11-01T00:00:00.000", + "Products.category": "Furniture", + "Products.productName": "Magna Visual Magnetic Picture Hangers", + "Products.subCategory": "Furnishings", }, Object { - "BigECommerce.count": 7, - "BigECommerce.totalCountRetailMonthAgo": 8, - "RetailCalendar.retail_date": "2020-12-01T00:00:00.000", - "RetailCalendar.retail_date.month": "2020-12-01T00:00:00.000", + "Products.category": "Furniture", + "Products.productName": "Anderson Hickey Conga Table Tops & Accessories", + "Products.subCategory": "Tables", }, Object { - "BigECommerce.count": null, - "BigECommerce.totalCountRetailMonthAgo": 7, - "RetailCalendar.retail_date": "2021-01-01T00:00:00.000", - "RetailCalendar.retail_date.month": "2021-01-01T00:00:00.000", + "Products.category": "Furniture", + "Products.productName": "Balt Solid Wood Rectangular Table", + "Products.subCategory": "Tables", }, ] `; -exports[`Queries with the @cubejs-backend/bigquery-driver Tesseract: querying BigECommerce with Retail Calendar: totalCountRetailWeekAgo 1`] = ` +exports[`Queries with the @cubejs-backend/bigquery-driver filtering Products: contains + dimensions + order, third 1`] = `Array []`; + +exports[`Queries with the @cubejs-backend/bigquery-driver filtering Products: contains with special chars + dimensions 1`] = ` Array [ Object { - "BigECommerce.count": 1, - "BigECommerce.totalCountRetailWeekAgo": null, - "RetailCalendar.retail_date": "2020-02-16T00:00:00.000", - "RetailCalendar.retail_date.week": "2020-02-16T00:00:00.000", + "Products.productName": "Logitech di_Novo Edge Keyboard", }, +] +`; + +exports[`Queries with the @cubejs-backend/bigquery-driver filtering Products: endsWith filter + dimensions + order, first 1`] = ` +Array [ Object { - "BigECommerce.count": null, - "BigECommerce.totalCountRetailWeekAgo": 1, - "RetailCalendar.retail_date": "2020-02-23T00:00:00.000", - "RetailCalendar.retail_date.week": "2020-02-23T00:00:00.000", + "Products.category": "Furniture", + "Products.productName": "DMI Eclipse Executive Suite Bookcases", + "Products.subCategory": "Bookcases", }, Object { - "BigECommerce.count": 1, - "BigECommerce.totalCountRetailWeekAgo": null, - "RetailCalendar.retail_date": "2020-03-15T00:00:00.000", - "RetailCalendar.retail_date.week": "2020-03-15T00:00:00.000", + "Products.category": "Furniture", + "Products.productName": "Global Adaptabilites Bookcase, Cherry/Storm Gray Finish", + "Products.subCategory": "Bookcases", }, Object { - "BigECommerce.count": 1, - "BigECommerce.totalCountRetailWeekAgo": 1, - "RetailCalendar.retail_date": "2020-03-22T00:00:00.000", - "RetailCalendar.retail_date.week": "2020-03-22T00:00:00.000", + "Products.category": "Furniture", + "Products.productName": "Anderson Hickey Conga Table Tops & Accessories", + "Products.subCategory": "Tables", }, Object { - "BigECommerce.count": null, - "BigECommerce.totalCountRetailWeekAgo": 1, - "RetailCalendar.retail_date": "2020-03-29T00:00:00.000", - "RetailCalendar.retail_date.week": "2020-03-29T00:00:00.000", + "Products.category": "Furniture", + "Products.productName": "Balt Solid Wood Rectangular Table", + "Products.subCategory": "Tables", }, Object { - "BigECommerce.count": 1, - "BigECommerce.totalCountRetailWeekAgo": null, - "RetailCalendar.retail_date": "2020-04-05T00:00:00.000", - "RetailCalendar.retail_date.week": "2020-04-05T00:00:00.000", + "Products.category": "Office Supplies", + "Products.productName": "Tyvek Side-Opening Peel & Seel Expanding Envelopes", + "Products.subCategory": "Envelopes", }, Object { - "BigECommerce.count": null, - "BigECommerce.totalCountRetailWeekAgo": 1, - "RetailCalendar.retail_date": "2020-04-12T00:00:00.000", - "RetailCalendar.retail_date.week": "2020-04-12T00:00:00.000", + "Products.category": "Office Supplies", + "Products.productName": "Wausau Papers Astrobrights Colored Envelopes", + "Products.subCategory": "Envelopes", }, Object { - "BigECommerce.count": 3, - "BigECommerce.totalCountRetailWeekAgo": null, - "RetailCalendar.retail_date": "2020-05-10T00:00:00.000", - "RetailCalendar.retail_date.week": "2020-05-10T00:00:00.000", + "Products.category": "Technology", + "Products.productName": "Kingston Digital DataTraveler 16GB USB 2.0", + "Products.subCategory": "Accessories", }, Object { - "BigECommerce.count": null, - "BigECommerce.totalCountRetailWeekAgo": 3, - "RetailCalendar.retail_date": "2020-05-17T00:00:00.000", - "RetailCalendar.retail_date.week": "2020-05-17T00:00:00.000", + "Products.category": "Technology", + "Products.productName": "Kingston Digital DataTraveler 16GB USB 2.1", + "Products.subCategory": "Accessories", }, Object { - "BigECommerce.count": 2, - "BigECommerce.totalCountRetailWeekAgo": null, - "RetailCalendar.retail_date": "2020-05-24T00:00:00.000", - "RetailCalendar.retail_date.week": "2020-05-24T00:00:00.000", + "Products.category": "Technology", + "Products.productName": "Kingston Digital DataTraveler 16GB USB 2.2", + "Products.subCategory": "Accessories", }, Object { - "BigECommerce.count": 1, - "BigECommerce.totalCountRetailWeekAgo": 2, - "RetailCalendar.retail_date": "2020-05-31T00:00:00.000", - "RetailCalendar.retail_date.week": "2020-05-31T00:00:00.000", + "Products.category": "Technology", + "Products.productName": "Logitech di_Novo Edge Keyboard", + "Products.subCategory": "Accessories", }, Object { - "BigECommerce.count": 2, - "BigECommerce.totalCountRetailWeekAgo": 1, - "RetailCalendar.retail_date": "2020-06-07T00:00:00.000", - "RetailCalendar.retail_date.week": "2020-06-07T00:00:00.000", + "Products.category": "Technology", + "Products.productName": "Lexmark 20R1285 X6650 Wireless All-in-One Printer", + "Products.subCategory": "Machines", }, Object { - "BigECommerce.count": 2, - "BigECommerce.totalCountRetailWeekAgo": 2, - "RetailCalendar.retail_date": "2020-06-14T00:00:00.000", - "RetailCalendar.retail_date.week": "2020-06-14T00:00:00.000", + "Products.category": "Technology", + "Products.productName": "Okidata C610n Printer", + "Products.subCategory": "Machines", }, Object { - "BigECommerce.count": 2, - "BigECommerce.totalCountRetailWeekAgo": 2, - "RetailCalendar.retail_date": "2020-06-21T00:00:00.000", - "RetailCalendar.retail_date.week": "2020-06-21T00:00:00.000", + "Products.category": "Technology", + "Products.productName": "Google Nexus 5", + "Products.subCategory": "Phones", }, Object { - "BigECommerce.count": null, - "BigECommerce.totalCountRetailWeekAgo": 2, - "RetailCalendar.retail_date": "2020-06-28T00:00:00.000", - "RetailCalendar.retail_date.week": "2020-06-28T00:00:00.000", + "Products.category": "Technology", + "Products.productName": "Google Nexus 6", + "Products.subCategory": "Phones", }, Object { - "BigECommerce.count": 2, - "BigECommerce.totalCountRetailWeekAgo": null, - "RetailCalendar.retail_date": "2020-08-30T00:00:00.000", - "RetailCalendar.retail_date.week": "2020-08-30T00:00:00.000", + "Products.category": "Technology", + "Products.productName": "Google Nexus 7", + "Products.subCategory": "Phones", }, Object { - "BigECommerce.count": 1, - "BigECommerce.totalCountRetailWeekAgo": 2, - "RetailCalendar.retail_date": "2020-09-06T00:00:00.000", - "RetailCalendar.retail_date.week": "2020-09-06T00:00:00.000", + "Products.category": "Technology", + "Products.productName": "HTC One", + "Products.subCategory": "Phones", }, +] +`; + +exports[`Queries with the @cubejs-backend/bigquery-driver filtering Products: endsWith filter + dimensions + order, second 1`] = ` +Array [ Object { - "BigECommerce.count": 2, - "BigECommerce.totalCountRetailWeekAgo": 1, - "RetailCalendar.retail_date": "2020-09-13T00:00:00.000", - "RetailCalendar.retail_date.week": "2020-09-13T00:00:00.000", + "Products.category": "Furniture", + "Products.productName": "DMI Eclipse Executive Suite Bookcases", + "Products.subCategory": "Bookcases", }, Object { - "BigECommerce.count": 1, - "BigECommerce.totalCountRetailWeekAgo": 2, - "RetailCalendar.retail_date": "2020-09-20T00:00:00.000", - "RetailCalendar.retail_date.week": "2020-09-20T00:00:00.000", + "Products.category": "Furniture", + "Products.productName": "Global Adaptabilites Bookcase, Cherry/Storm Gray Finish", + "Products.subCategory": "Bookcases", }, Object { - "BigECommerce.count": null, - "BigECommerce.totalCountRetailWeekAgo": 1, - "RetailCalendar.retail_date": "2020-09-27T00:00:00.000", - "RetailCalendar.retail_date.week": "2020-09-27T00:00:00.000", + "Products.category": "Furniture", + "Products.productName": "Linden 10 Round Wall Clock, Black", + "Products.subCategory": "Furnishings", }, Object { - "BigECommerce.count": 1, - "BigECommerce.totalCountRetailWeekAgo": null, - "RetailCalendar.retail_date": "2020-10-11T00:00:00.000", - "RetailCalendar.retail_date.week": "2020-10-11T00:00:00.000", + "Products.category": "Furniture", + "Products.productName": "Magna Visual Magnetic Picture Hangers", + "Products.subCategory": "Furnishings", }, Object { - "BigECommerce.count": 2, - "BigECommerce.totalCountRetailWeekAgo": 1, - "RetailCalendar.retail_date": "2020-10-18T00:00:00.000", - "RetailCalendar.retail_date.week": "2020-10-18T00:00:00.000", + "Products.category": "Furniture", + "Products.productName": "Anderson Hickey Conga Table Tops & Accessories", + "Products.subCategory": "Tables", }, Object { - "BigECommerce.count": 1, - "BigECommerce.totalCountRetailWeekAgo": 2, - "RetailCalendar.retail_date": "2020-10-25T00:00:00.000", - "RetailCalendar.retail_date.week": "2020-10-25T00:00:00.000", + "Products.category": "Furniture", + "Products.productName": "Balt Solid Wood Rectangular Table", + "Products.subCategory": "Tables", }, Object { - "BigECommerce.count": 3, - "BigECommerce.totalCountRetailWeekAgo": 1, - "RetailCalendar.retail_date": "2020-11-01T00:00:00.000", - "RetailCalendar.retail_date.week": "2020-11-01T00:00:00.000", + "Products.category": "Office Supplies", + "Products.productName": "Tyvek Side-Opening Peel & Seel Expanding Envelopes", + "Products.subCategory": "Envelopes", }, Object { - "BigECommerce.count": 2, - "BigECommerce.totalCountRetailWeekAgo": 3, - "RetailCalendar.retail_date": "2020-11-08T00:00:00.000", - "RetailCalendar.retail_date.week": "2020-11-08T00:00:00.000", + "Products.category": "Office Supplies", + "Products.productName": "Wausau Papers Astrobrights Colored Envelopes", + "Products.subCategory": "Envelopes", }, Object { - "BigECommerce.count": 3, - "BigECommerce.totalCountRetailWeekAgo": 2, - "RetailCalendar.retail_date": "2020-11-15T00:00:00.000", - "RetailCalendar.retail_date.week": "2020-11-15T00:00:00.000", + "Products.category": "Technology", + "Products.productName": "Kingston Digital DataTraveler 16GB USB 2.0", + "Products.subCategory": "Accessories", }, Object { - "BigECommerce.count": 1, - "BigECommerce.totalCountRetailWeekAgo": 3, - "RetailCalendar.retail_date": "2020-11-22T00:00:00.000", - "RetailCalendar.retail_date.week": "2020-11-22T00:00:00.000", + "Products.category": "Technology", + "Products.productName": "Kingston Digital DataTraveler 16GB USB 2.1", + "Products.subCategory": "Accessories", }, Object { - "BigECommerce.count": 3, - "BigECommerce.totalCountRetailWeekAgo": 1, - "RetailCalendar.retail_date": "2020-11-29T00:00:00.000", - "RetailCalendar.retail_date.week": "2020-11-29T00:00:00.000", + "Products.category": "Technology", + "Products.productName": "Kingston Digital DataTraveler 16GB USB 2.2", + "Products.subCategory": "Accessories", }, Object { - "BigECommerce.count": null, - "BigECommerce.totalCountRetailWeekAgo": 3, - "RetailCalendar.retail_date": "2020-12-06T00:00:00.000", - "RetailCalendar.retail_date.week": "2020-12-06T00:00:00.000", + "Products.category": "Technology", + "Products.productName": "Logitech di_Novo Edge Keyboard", + "Products.subCategory": "Accessories", }, Object { - "BigECommerce.count": 2, - "BigECommerce.totalCountRetailWeekAgo": null, - "RetailCalendar.retail_date": "2020-12-13T00:00:00.000", - "RetailCalendar.retail_date.week": "2020-12-13T00:00:00.000", + "Products.category": "Technology", + "Products.productName": "Lexmark 20R1285 X6650 Wireless All-in-One Printer", + "Products.subCategory": "Machines", }, Object { - "BigECommerce.count": 2, - "BigECommerce.totalCountRetailWeekAgo": 2, - "RetailCalendar.retail_date": "2020-12-20T00:00:00.000", - "RetailCalendar.retail_date.week": "2020-12-20T00:00:00.000", + "Products.category": "Technology", + "Products.productName": "Okidata C610n Printer", + "Products.subCategory": "Machines", }, Object { - "BigECommerce.count": null, - "BigECommerce.totalCountRetailWeekAgo": 2, - "RetailCalendar.retail_date": "2020-12-27T00:00:00.000", - "RetailCalendar.retail_date.week": "2020-12-27T00:00:00.000", + "Products.category": "Technology", + "Products.productName": "Google Nexus 5", + "Products.subCategory": "Phones", }, -] -`; - -exports[`Queries with the @cubejs-backend/bigquery-driver Tesseract: SQL API: Timeshift measure from cube 1`] = ` -Array [ Object { - "orderDate": 2020-01-01T00:00:00.000Z, - "totalQuantity": 6, - "totalQuantityPriorMonth": null, + "Products.category": "Technology", + "Products.productName": "Google Nexus 6", + "Products.subCategory": "Phones", }, Object { - "orderDate": 2020-02-01T00:00:00.000Z, - "totalQuantity": 2, - "totalQuantityPriorMonth": 6, + "Products.category": "Technology", + "Products.productName": "Google Nexus 7", + "Products.subCategory": "Phones", }, Object { - "orderDate": 2020-03-01T00:00:00.000Z, - "totalQuantity": 13, - "totalQuantityPriorMonth": 2, + "Products.category": "Technology", + "Products.productName": "HTC One", + "Products.subCategory": "Phones", }, +] +`; + +exports[`Queries with the @cubejs-backend/bigquery-driver filtering Products: endsWith filter + dimensions + order, third 1`] = `Array []`; + +exports[`Queries with the @cubejs-backend/bigquery-driver filtering Products: startsWith filter + dimensions + order, first 1`] = ` +Array [ Object { - "orderDate": 2020-04-01T00:00:00.000Z, - "totalQuantity": 3, - "totalQuantityPriorMonth": 13, + "Products.category": "Office Supplies", + "Products.productName": "OIC #2 Pencils, Medium Soft", + "Products.subCategory": "Art", }, Object { - "orderDate": 2020-05-01T00:00:00.000Z, - "totalQuantity": 15, - "totalQuantityPriorMonth": 3, + "Products.category": "Technology", + "Products.productName": "Okidata C610n Printer", + "Products.subCategory": "Machines", }, +] +`; + +exports[`Queries with the @cubejs-backend/bigquery-driver filtering Products: startsWith filter + dimensions + order, second 1`] = ` +Array [ Object { - "orderDate": 2020-06-01T00:00:00.000Z, - "totalQuantity": 18, - "totalQuantityPriorMonth": 15, + "Products.category": "Office Supplies", + "Products.productName": "OIC #2 Pencils, Medium Soft", + "Products.subCategory": "Art", }, Object { - "orderDate": 2020-07-01T00:00:00.000Z, - "totalQuantity": null, - "totalQuantityPriorMonth": 18, + "Products.category": "Technology", + "Products.productName": "Kingston Digital DataTraveler 16GB USB 2.0", + "Products.subCategory": "Accessories", }, Object { - "orderDate": 2020-09-01T00:00:00.000Z, - "totalQuantity": 27, - "totalQuantityPriorMonth": null, + "Products.category": "Technology", + "Products.productName": "Kingston Digital DataTraveler 16GB USB 2.1", + "Products.subCategory": "Accessories", }, Object { - "orderDate": 2020-10-01T00:00:00.000Z, - "totalQuantity": 11, - "totalQuantityPriorMonth": 27, + "Products.category": "Technology", + "Products.productName": "Kingston Digital DataTraveler 16GB USB 2.2", + "Products.subCategory": "Accessories", }, Object { - "orderDate": 2020-11-01T00:00:00.000Z, - "totalQuantity": 43, - "totalQuantityPriorMonth": 11, + "Products.category": "Technology", + "Products.productName": "Okidata C610n Printer", + "Products.subCategory": "Machines", }, +] +`; + +exports[`Queries with the @cubejs-backend/bigquery-driver filtering Products: startsWith filter + dimensions + order, third 1`] = `Array []`; + +exports[`Queries with the @cubejs-backend/bigquery-driver pre-aggregations Customers: running total without time dimension 1`] = ` +Array [ Object { - "orderDate": 2020-12-01T00:00:00.000Z, - "totalQuantity": 22, - "totalQuantityPriorMonth": 43, + "Customers.runningTotal": "41", }, ] `; @@ -6843,6 +6768,81 @@ Array [ ] `; +exports[`Queries with the @cubejs-backend/bigquery-driver querying BigECommerce: multi-stage group by time dimension 1`] = ` +Array [ + Object { + "BigECommerce.orderDate": "2020-01-01T00:00:00.000", + "BigECommerce.orderDate.month": "2020-01-01T00:00:00.000", + "BigECommerce.orderDate.quarter": "2020-01-01T00:00:00.000", + "BigECommerce.totalProfit": "29.65480", + "BigECommerce.totalProfitForQuarter": "619.44850", + }, + Object { + "BigECommerce.orderDate": "2020-02-01T00:00:00.000", + "BigECommerce.orderDate.month": "2020-02-01T00:00:00.000", + "BigECommerce.orderDate.quarter": "2020-01-01T00:00:00.000", + "BigECommerce.totalProfit": "6.19920", + "BigECommerce.totalProfitForQuarter": "619.44850", + }, + Object { + "BigECommerce.orderDate": "2020-03-01T00:00:00.000", + "BigECommerce.orderDate.month": "2020-03-01T00:00:00.000", + "BigECommerce.orderDate.quarter": "2020-01-01T00:00:00.000", + "BigECommerce.totalProfit": "583.59450", + "BigECommerce.totalProfitForQuarter": "619.44850", + }, + Object { + "BigECommerce.orderDate": "2020-04-01T00:00:00.000", + "BigECommerce.orderDate.month": "2020-04-01T00:00:00.000", + "BigECommerce.orderDate.quarter": "2020-04-01T00:00:00.000", + "BigECommerce.totalProfit": "6.41760", + "BigECommerce.totalProfitForQuarter": "394.33860", + }, + Object { + "BigECommerce.orderDate": "2020-05-01T00:00:00.000", + "BigECommerce.orderDate.month": "2020-05-01T00:00:00.000", + "BigECommerce.orderDate.quarter": "2020-04-01T00:00:00.000", + "BigECommerce.totalProfit": "353.68490", + "BigECommerce.totalProfitForQuarter": "394.33860", + }, + Object { + "BigECommerce.orderDate": "2020-06-01T00:00:00.000", + "BigECommerce.orderDate.month": "2020-06-01T00:00:00.000", + "BigECommerce.orderDate.quarter": "2020-04-01T00:00:00.000", + "BigECommerce.totalProfit": "34.23610", + "BigECommerce.totalProfitForQuarter": "394.33860", + }, + Object { + "BigECommerce.orderDate": "2020-09-01T00:00:00.000", + "BigECommerce.orderDate.month": "2020-09-01T00:00:00.000", + "BigECommerce.orderDate.quarter": "2020-07-01T00:00:00.000", + "BigECommerce.totalProfit": "461.13320", + "BigECommerce.totalProfitForQuarter": "461.13320", + }, + Object { + "BigECommerce.orderDate": "2020-10-01T00:00:00.000", + "BigECommerce.orderDate.month": "2020-10-01T00:00:00.000", + "BigECommerce.orderDate.quarter": "2020-10-01T00:00:00.000", + "BigECommerce.totalProfit": "139.99700", + "BigECommerce.totalProfitForQuarter": "1576.63240", + }, + Object { + "BigECommerce.orderDate": "2020-11-01T00:00:00.000", + "BigECommerce.orderDate.month": "2020-11-01T00:00:00.000", + "BigECommerce.orderDate.quarter": "2020-10-01T00:00:00.000", + "BigECommerce.totalProfit": "1132.66170", + "BigECommerce.totalProfitForQuarter": "1576.63240", + }, + Object { + "BigECommerce.orderDate": "2020-12-01T00:00:00.000", + "BigECommerce.orderDate.month": "2020-12-01T00:00:00.000", + "BigECommerce.orderDate.quarter": "2020-10-01T00:00:00.000", + "BigECommerce.totalProfit": "303.97370", + "BigECommerce.totalProfitForQuarter": "1576.63240", + }, +] +`; + exports[`Queries with the @cubejs-backend/bigquery-driver querying BigECommerce: partitioned pre-agg 1`] = ` Array [ Object { @@ -13155,6 +13155,111 @@ Array [ ] `; +exports[`Queries with the @cubejs-backend/bigquery-driver querying SwitchSourceTest: filter by switch dimensions 1`] = ` +Array [ + Object { + "SwitchSourceTest.city": "Detroit", + "SwitchSourceTest.orderDate": "2020-01-01T00:00:00.000", + "SwitchSourceTest.orderDate.month": "2020-01-01T00:00:00.000", + "SwitchSourceTest.totalSales": 210.98, + }, + Object { + "SwitchSourceTest.city": "Lorain", + "SwitchSourceTest.orderDate": "2020-01-01T00:00:00.000", + "SwitchSourceTest.orderDate.month": "2020-01-01T00:00:00.000", + "SwitchSourceTest.totalSales": 48.896, + }, + Object { + "SwitchSourceTest.city": "Decatur", + "SwitchSourceTest.orderDate": "2020-02-01T00:00:00.000", + "SwitchSourceTest.orderDate.month": "2020-02-01T00:00:00.000", + "SwitchSourceTest.totalSales": 18.368, + }, + Object { + "SwitchSourceTest.city": "Houston", + "SwitchSourceTest.orderDate": "2020-03-01T00:00:00.000", + "SwitchSourceTest.orderDate.month": "2020-03-01T00:00:00.000", + "SwitchSourceTest.totalSales": 2399.96, + }, + Object { + "SwitchSourceTest.city": "New York City", + "SwitchSourceTest.orderDate": "2020-03-01T00:00:00.000", + "SwitchSourceTest.orderDate.month": "2020-03-01T00:00:00.000", + "SwitchSourceTest.totalSales": 71.6, + }, +] +`; + +exports[`Queries with the @cubejs-backend/bigquery-driver querying SwitchSourceTest: full cross join 1`] = ` +Array [ + Object { + "SwitchSourceTest.city": "Detroit", + "SwitchSourceTest.orderDate": "2020-01-01T00:00:00.000", + "SwitchSourceTest.orderDate.month": "2020-01-01T00:00:00.000", + "SwitchSourceTest.totalSales": 1265.8799999999999, + }, + Object { + "SwitchSourceTest.city": "Lorain", + "SwitchSourceTest.orderDate": "2020-01-01T00:00:00.000", + "SwitchSourceTest.orderDate.month": "2020-01-01T00:00:00.000", + "SwitchSourceTest.totalSales": 293.376, + }, + Object { + "SwitchSourceTest.city": "Decatur", + "SwitchSourceTest.orderDate": "2020-02-01T00:00:00.000", + "SwitchSourceTest.orderDate.month": "2020-02-01T00:00:00.000", + "SwitchSourceTest.totalSales": 110.208, + }, + Object { + "SwitchSourceTest.city": "Houston", + "SwitchSourceTest.orderDate": "2020-03-01T00:00:00.000", + "SwitchSourceTest.orderDate.month": "2020-03-01T00:00:00.000", + "SwitchSourceTest.totalSales": 14399.76, + }, + Object { + "SwitchSourceTest.city": "New York City", + "SwitchSourceTest.orderDate": "2020-03-01T00:00:00.000", + "SwitchSourceTest.orderDate.month": "2020-03-01T00:00:00.000", + "SwitchSourceTest.totalSales": 429.59999999999997, + }, +] +`; + +exports[`Queries with the @cubejs-backend/bigquery-driver querying SwitchSourceTest: simple cross join 1`] = ` +Array [ + Object { + "SwitchSourceTest.city": "Detroit", + "SwitchSourceTest.orderDate": "2020-01-01T00:00:00.000", + "SwitchSourceTest.orderDate.month": "2020-01-01T00:00:00.000", + "SwitchSourceTest.totalSalesA": 421.96, + }, + Object { + "SwitchSourceTest.city": "Lorain", + "SwitchSourceTest.orderDate": "2020-01-01T00:00:00.000", + "SwitchSourceTest.orderDate.month": "2020-01-01T00:00:00.000", + "SwitchSourceTest.totalSalesA": 97.792, + }, + Object { + "SwitchSourceTest.city": "Decatur", + "SwitchSourceTest.orderDate": "2020-02-01T00:00:00.000", + "SwitchSourceTest.orderDate.month": "2020-02-01T00:00:00.000", + "SwitchSourceTest.totalSalesA": 36.736, + }, + Object { + "SwitchSourceTest.city": "Houston", + "SwitchSourceTest.orderDate": "2020-03-01T00:00:00.000", + "SwitchSourceTest.orderDate.month": "2020-03-01T00:00:00.000", + "SwitchSourceTest.totalSalesA": 4799.92, + }, + Object { + "SwitchSourceTest.city": "New York City", + "SwitchSourceTest.orderDate": "2020-03-01T00:00:00.000", + "SwitchSourceTest.orderDate.month": "2020-03-01T00:00:00.000", + "SwitchSourceTest.totalSalesA": 143.2, + }, +] +`; + exports[`Queries with the @cubejs-backend/bigquery-driver querying custom granularities (with preaggregation) ECommerce: totalQuantity by half_year + dimension 1`] = ` Array [ Object { diff --git a/packages/cubejs-testing-drivers/test/__snapshots__/databricks-jdbc-full.test.ts.snap b/packages/cubejs-testing-drivers/test/__snapshots__/databricks-jdbc-full.test.ts.snap index 14e1053b45d13..5ca7d42735a38 100644 --- a/packages/cubejs-testing-drivers/test/__snapshots__/databricks-jdbc-full.test.ts.snap +++ b/packages/cubejs-testing-drivers/test/__snapshots__/databricks-jdbc-full.test.ts.snap @@ -1,79 +1,5 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP -exports[`Queries with the @cubejs-backend/databricks-jdbc-driver querying BigECommerce: multi-stage group by time dimension 1`] = ` -Array [ - Object { - "BigECommerce.orderDate": "2020-01-01T00:00:00.000", - "BigECommerce.orderDate.month": "2020-01-01T00:00:00.000", - "BigECommerce.orderDate.quarter": "2020-01-01T00:00:00.000", - "BigECommerce.totalProfit": 29.6548, - "BigECommerce.totalProfitForQuarter": 619.4485, - }, - Object { - "BigECommerce.orderDate": "2020-02-01T00:00:00.000", - "BigECommerce.orderDate.month": "2020-02-01T00:00:00.000", - "BigECommerce.orderDate.quarter": "2020-01-01T00:00:00.000", - "BigECommerce.totalProfit": 6.1992, - "BigECommerce.totalProfitForQuarter": 619.4485, - }, - Object { - "BigECommerce.orderDate": "2020-03-01T00:00:00.000", - "BigECommerce.orderDate.month": "2020-03-01T00:00:00.000", - "BigECommerce.orderDate.quarter": "2020-01-01T00:00:00.000", - "BigECommerce.totalProfit": 583.5945, - "BigECommerce.totalProfitForQuarter": 619.4485, - }, - Object { - "BigECommerce.orderDate": "2020-04-01T00:00:00.000", - "BigECommerce.orderDate.month": "2020-04-01T00:00:00.000", - "BigECommerce.orderDate.quarter": "2020-04-01T00:00:00.000", - "BigECommerce.totalProfit": 6.4176, - "BigECommerce.totalProfitForQuarter": 394.3386, - }, - Object { - "BigECommerce.orderDate": "2020-05-01T00:00:00.000", - "BigECommerce.orderDate.month": "2020-05-01T00:00:00.000", - "BigECommerce.orderDate.quarter": "2020-04-01T00:00:00.000", - "BigECommerce.totalProfit": 353.6849, - "BigECommerce.totalProfitForQuarter": 394.3386, - }, - Object { - "BigECommerce.orderDate": "2020-06-01T00:00:00.000", - "BigECommerce.orderDate.month": "2020-06-01T00:00:00.000", - "BigECommerce.orderDate.quarter": "2020-04-01T00:00:00.000", - "BigECommerce.totalProfit": 34.2361, - "BigECommerce.totalProfitForQuarter": 394.3386, - }, - Object { - "BigECommerce.orderDate": "2020-09-01T00:00:00.000", - "BigECommerce.orderDate.month": "2020-09-01T00:00:00.000", - "BigECommerce.orderDate.quarter": "2020-07-01T00:00:00.000", - "BigECommerce.totalProfit": 461.1332, - "BigECommerce.totalProfitForQuarter": 461.1332, - }, - Object { - "BigECommerce.orderDate": "2020-10-01T00:00:00.000", - "BigECommerce.orderDate.month": "2020-10-01T00:00:00.000", - "BigECommerce.orderDate.quarter": "2020-10-01T00:00:00.000", - "BigECommerce.totalProfit": 139.997, - "BigECommerce.totalProfitForQuarter": 1576.6324, - }, - Object { - "BigECommerce.orderDate": "2020-11-01T00:00:00.000", - "BigECommerce.orderDate.month": "2020-11-01T00:00:00.000", - "BigECommerce.orderDate.quarter": "2020-10-01T00:00:00.000", - "BigECommerce.totalProfit": 1132.6617, - "BigECommerce.totalProfitForQuarter": 1576.6324, - }, - Object { - "BigECommerce.orderDate": "2020-12-01T00:00:00.000", - "BigECommerce.orderDate.month": "2020-12-01T00:00:00.000", - "BigECommerce.orderDate.quarter": "2020-10-01T00:00:00.000", - "BigECommerce.totalProfit": 303.9737, - "BigECommerce.totalProfitForQuarter": 1576.6324, - }, -] -`; exports[`Queries with the @cubejs-backend/databricks-jdbc-driver SQL API: Complex Rollup 1`] = ` Array [ Object { @@ -9539,6 +9465,81 @@ Array [ ] `; +exports[`Queries with the @cubejs-backend/databricks-jdbc-driver querying BigECommerce: multi-stage group by time dimension 1`] = ` +Array [ + Object { + "BigECommerce.orderDate": "2020-01-01T00:00:00.000", + "BigECommerce.orderDate.month": "2020-01-01T00:00:00.000", + "BigECommerce.orderDate.quarter": "2020-01-01T00:00:00.000", + "BigECommerce.totalProfit": 29.6548, + "BigECommerce.totalProfitForQuarter": 619.4485, + }, + Object { + "BigECommerce.orderDate": "2020-02-01T00:00:00.000", + "BigECommerce.orderDate.month": "2020-02-01T00:00:00.000", + "BigECommerce.orderDate.quarter": "2020-01-01T00:00:00.000", + "BigECommerce.totalProfit": 6.1992, + "BigECommerce.totalProfitForQuarter": 619.4485, + }, + Object { + "BigECommerce.orderDate": "2020-03-01T00:00:00.000", + "BigECommerce.orderDate.month": "2020-03-01T00:00:00.000", + "BigECommerce.orderDate.quarter": "2020-01-01T00:00:00.000", + "BigECommerce.totalProfit": 583.5945, + "BigECommerce.totalProfitForQuarter": 619.4485, + }, + Object { + "BigECommerce.orderDate": "2020-04-01T00:00:00.000", + "BigECommerce.orderDate.month": "2020-04-01T00:00:00.000", + "BigECommerce.orderDate.quarter": "2020-04-01T00:00:00.000", + "BigECommerce.totalProfit": 6.4176, + "BigECommerce.totalProfitForQuarter": 394.3386, + }, + Object { + "BigECommerce.orderDate": "2020-05-01T00:00:00.000", + "BigECommerce.orderDate.month": "2020-05-01T00:00:00.000", + "BigECommerce.orderDate.quarter": "2020-04-01T00:00:00.000", + "BigECommerce.totalProfit": 353.6849, + "BigECommerce.totalProfitForQuarter": 394.3386, + }, + Object { + "BigECommerce.orderDate": "2020-06-01T00:00:00.000", + "BigECommerce.orderDate.month": "2020-06-01T00:00:00.000", + "BigECommerce.orderDate.quarter": "2020-04-01T00:00:00.000", + "BigECommerce.totalProfit": 34.2361, + "BigECommerce.totalProfitForQuarter": 394.3386, + }, + Object { + "BigECommerce.orderDate": "2020-09-01T00:00:00.000", + "BigECommerce.orderDate.month": "2020-09-01T00:00:00.000", + "BigECommerce.orderDate.quarter": "2020-07-01T00:00:00.000", + "BigECommerce.totalProfit": 461.1332, + "BigECommerce.totalProfitForQuarter": 461.1332, + }, + Object { + "BigECommerce.orderDate": "2020-10-01T00:00:00.000", + "BigECommerce.orderDate.month": "2020-10-01T00:00:00.000", + "BigECommerce.orderDate.quarter": "2020-10-01T00:00:00.000", + "BigECommerce.totalProfit": 139.997, + "BigECommerce.totalProfitForQuarter": 1576.6324, + }, + Object { + "BigECommerce.orderDate": "2020-11-01T00:00:00.000", + "BigECommerce.orderDate.month": "2020-11-01T00:00:00.000", + "BigECommerce.orderDate.quarter": "2020-10-01T00:00:00.000", + "BigECommerce.totalProfit": 1132.6617, + "BigECommerce.totalProfitForQuarter": 1576.6324, + }, + Object { + "BigECommerce.orderDate": "2020-12-01T00:00:00.000", + "BigECommerce.orderDate.month": "2020-12-01T00:00:00.000", + "BigECommerce.orderDate.quarter": "2020-10-01T00:00:00.000", + "BigECommerce.totalProfit": 303.9737, + "BigECommerce.totalProfitForQuarter": 1576.6324, + }, +] +`; + exports[`Queries with the @cubejs-backend/databricks-jdbc-driver querying BigECommerce: null boolean 1`] = ` Array [ Object { @@ -16330,6 +16331,110 @@ Array [ ] `; +exports[`Queries with the @cubejs-backend/databricks-jdbc-driver querying SwitchSourceTest: filter by switch dimensions 1`] = ` +Array [ + Object { + "SwitchSourceTest.city": "Detroit", + "SwitchSourceTest.orderDate": "2020-01-01T00:00:00.000", + "SwitchSourceTest.orderDate.month": "2020-01-01T00:00:00.000", + "SwitchSourceTest.totalSales": 210.98, + }, + Object { + "SwitchSourceTest.city": "Lorain", + "SwitchSourceTest.orderDate": "2020-01-01T00:00:00.000", + "SwitchSourceTest.orderDate.month": "2020-01-01T00:00:00.000", + "SwitchSourceTest.totalSales": 48.896, + }, + Object { + "SwitchSourceTest.city": "Decatur", + "SwitchSourceTest.orderDate": "2020-02-01T00:00:00.000", + "SwitchSourceTest.orderDate.month": "2020-02-01T00:00:00.000", + "SwitchSourceTest.totalSales": 18.368, + }, + Object { + "SwitchSourceTest.city": "Houston", + "SwitchSourceTest.orderDate": "2020-03-01T00:00:00.000", + "SwitchSourceTest.orderDate.month": "2020-03-01T00:00:00.000", + "SwitchSourceTest.totalSales": 2399.96, + }, + Object { + "SwitchSourceTest.city": "New York City", + "SwitchSourceTest.orderDate": "2020-03-01T00:00:00.000", + "SwitchSourceTest.orderDate.month": "2020-03-01T00:00:00.000", + "SwitchSourceTest.totalSales": 71.6, + }, +] +`; + +exports[`Queries with the @cubejs-backend/databricks-jdbc-driver querying SwitchSourceTest: full cross join 1`] = ` +Array [ + Object { + "SwitchSourceTest.city": "Detroit", + "SwitchSourceTest.orderDate": "2020-01-01T00:00:00.000", + "SwitchSourceTest.orderDate.month": "2020-01-01T00:00:00.000", + "SwitchSourceTest.totalSales": 1265.88, + }, + Object { + "SwitchSourceTest.city": "Lorain", + "SwitchSourceTest.orderDate": "2020-01-01T00:00:00.000", + "SwitchSourceTest.orderDate.month": "2020-01-01T00:00:00.000", + "SwitchSourceTest.totalSales": 293.376, + }, + Object { + "SwitchSourceTest.city": "Decatur", + "SwitchSourceTest.orderDate": "2020-02-01T00:00:00.000", + "SwitchSourceTest.orderDate.month": "2020-02-01T00:00:00.000", + "SwitchSourceTest.totalSales": 110.208, + }, + Object { + "SwitchSourceTest.city": "Houston", + "SwitchSourceTest.orderDate": "2020-03-01T00:00:00.000", + "SwitchSourceTest.orderDate.month": "2020-03-01T00:00:00.000", + "SwitchSourceTest.totalSales": 14399.76, + }, + Object { + "SwitchSourceTest.city": "New York City", + "SwitchSourceTest.orderDate": "2020-03-01T00:00:00.000", + "SwitchSourceTest.orderDate.month": "2020-03-01T00:00:00.000", + "SwitchSourceTest.totalSales": 429.6, + }, +] +`; + +exports[`Queries with the @cubejs-backend/databricks-jdbc-driver querying SwitchSourceTest: simple cross join 1`] = ` +Array [ + Object { + "SwitchSourceTest.city": "Detroit", + "SwitchSourceTest.orderDate": "2020-01-01T00:00:00.000", + "SwitchSourceTest.orderDate.month": "2020-01-01T00:00:00.000", + "SwitchSourceTest.totalSalesA": 421.96, + }, + Object { + "SwitchSourceTest.city": "Lorain", + "SwitchSourceTest.orderDate": "2020-01-01T00:00:00.000", + "SwitchSourceTest.orderDate.month": "2020-01-01T00:00:00.000", + "SwitchSourceTest.totalSalesA": 97.792, + }, + Object { + "SwitchSourceTest.city": "Decatur", + "SwitchSourceTest.orderDate": "2020-02-01T00:00:00.000", + "SwitchSourceTest.orderDate.month": "2020-02-01T00:00:00.000", + "SwitchSourceTest.totalSalesA": 36.736, + }, + Object { + "SwitchSourceTest.city": "Houston", + "SwitchSourceTest.orderDate": "2020-03-01T00:00:00.000", + "SwitchSourceTest.orderDate.month": "2020-03-01T00:00:00.000", + "SwitchSourceTest.totalSalesA": 4799.92, + }, + Object { + "SwitchSourceTest.city": "New York City", + "SwitchSourceTest.orderDate": "2020-03-01T00:00:00.000", + "SwitchSourceTest.orderDate.month": "2020-03-01T00:00:00.000", + "SwitchSourceTest.totalSalesA": 143.2, + }, +] +`; exports[`Queries with the @cubejs-backend/databricks-jdbc-driver querying custom granularities ECommerce: count by half_year_by_1st_april + dimension 1`] = ` Array [ Object { diff --git a/packages/cubejs-testing-drivers/test/__snapshots__/postgres-full.test.ts.snap b/packages/cubejs-testing-drivers/test/__snapshots__/postgres-full.test.ts.snap index c3c890744fe26..5ed319d9904e0 100644 --- a/packages/cubejs-testing-drivers/test/__snapshots__/postgres-full.test.ts.snap +++ b/packages/cubejs-testing-drivers/test/__snapshots__/postgres-full.test.ts.snap @@ -18121,6 +18121,111 @@ Array [ ] `; +exports[`Queries with the @cubejs-backend/postgres-driver querying SwitchSourceTest: filter by switch dimensions 1`] = ` +Array [ + Object { + "SwitchSourceTest.city": "Detroit", + "SwitchSourceTest.orderDate": "2020-01-01T00:00:00.000", + "SwitchSourceTest.orderDate.month": "2020-01-01T00:00:00.000", + "SwitchSourceTest.totalSales": "210.98000", + }, + Object { + "SwitchSourceTest.city": "Lorain", + "SwitchSourceTest.orderDate": "2020-01-01T00:00:00.000", + "SwitchSourceTest.orderDate.month": "2020-01-01T00:00:00.000", + "SwitchSourceTest.totalSales": "48.89600", + }, + Object { + "SwitchSourceTest.city": "Decatur", + "SwitchSourceTest.orderDate": "2020-02-01T00:00:00.000", + "SwitchSourceTest.orderDate.month": "2020-02-01T00:00:00.000", + "SwitchSourceTest.totalSales": "18.36800", + }, + Object { + "SwitchSourceTest.city": "Houston", + "SwitchSourceTest.orderDate": "2020-03-01T00:00:00.000", + "SwitchSourceTest.orderDate.month": "2020-03-01T00:00:00.000", + "SwitchSourceTest.totalSales": "2399.96000", + }, + Object { + "SwitchSourceTest.city": "New York City", + "SwitchSourceTest.orderDate": "2020-03-01T00:00:00.000", + "SwitchSourceTest.orderDate.month": "2020-03-01T00:00:00.000", + "SwitchSourceTest.totalSales": "71.60000", + }, +] +`; + +exports[`Queries with the @cubejs-backend/postgres-driver querying SwitchSourceTest: full cross join 1`] = ` +Array [ + Object { + "SwitchSourceTest.city": "Detroit", + "SwitchSourceTest.orderDate": "2020-01-01T00:00:00.000", + "SwitchSourceTest.orderDate.month": "2020-01-01T00:00:00.000", + "SwitchSourceTest.totalSales": "1265.88000", + }, + Object { + "SwitchSourceTest.city": "Lorain", + "SwitchSourceTest.orderDate": "2020-01-01T00:00:00.000", + "SwitchSourceTest.orderDate.month": "2020-01-01T00:00:00.000", + "SwitchSourceTest.totalSales": "293.37600", + }, + Object { + "SwitchSourceTest.city": "Decatur", + "SwitchSourceTest.orderDate": "2020-02-01T00:00:00.000", + "SwitchSourceTest.orderDate.month": "2020-02-01T00:00:00.000", + "SwitchSourceTest.totalSales": "110.20800", + }, + Object { + "SwitchSourceTest.city": "Houston", + "SwitchSourceTest.orderDate": "2020-03-01T00:00:00.000", + "SwitchSourceTest.orderDate.month": "2020-03-01T00:00:00.000", + "SwitchSourceTest.totalSales": "14399.76000", + }, + Object { + "SwitchSourceTest.city": "New York City", + "SwitchSourceTest.orderDate": "2020-03-01T00:00:00.000", + "SwitchSourceTest.orderDate.month": "2020-03-01T00:00:00.000", + "SwitchSourceTest.totalSales": "429.60000", + }, +] +`; + +exports[`Queries with the @cubejs-backend/postgres-driver querying SwitchSourceTest: simple cross join 1`] = ` +Array [ + Object { + "SwitchSourceTest.city": "Detroit", + "SwitchSourceTest.orderDate": "2020-01-01T00:00:00.000", + "SwitchSourceTest.orderDate.month": "2020-01-01T00:00:00.000", + "SwitchSourceTest.totalSalesA": "421.96000", + }, + Object { + "SwitchSourceTest.city": "Lorain", + "SwitchSourceTest.orderDate": "2020-01-01T00:00:00.000", + "SwitchSourceTest.orderDate.month": "2020-01-01T00:00:00.000", + "SwitchSourceTest.totalSalesA": "97.79200", + }, + Object { + "SwitchSourceTest.city": "Decatur", + "SwitchSourceTest.orderDate": "2020-02-01T00:00:00.000", + "SwitchSourceTest.orderDate.month": "2020-02-01T00:00:00.000", + "SwitchSourceTest.totalSalesA": "36.73600", + }, + Object { + "SwitchSourceTest.city": "Houston", + "SwitchSourceTest.orderDate": "2020-03-01T00:00:00.000", + "SwitchSourceTest.orderDate.month": "2020-03-01T00:00:00.000", + "SwitchSourceTest.totalSalesA": "4799.92000", + }, + Object { + "SwitchSourceTest.city": "New York City", + "SwitchSourceTest.orderDate": "2020-03-01T00:00:00.000", + "SwitchSourceTest.orderDate.month": "2020-03-01T00:00:00.000", + "SwitchSourceTest.totalSalesA": "143.20000", + }, +] +`; + exports[`Queries with the @cubejs-backend/postgres-driver querying custom granularities (with preaggregation) ECommerce: totalQuantity by half_year + dimension 1`] = ` Array [ Object { diff --git a/packages/cubejs-testing-drivers/test/__snapshots__/redshift-full.test.ts.snap b/packages/cubejs-testing-drivers/test/__snapshots__/redshift-full.test.ts.snap index d869ceed038ea..1d9d4dcea0331 100644 --- a/packages/cubejs-testing-drivers/test/__snapshots__/redshift-full.test.ts.snap +++ b/packages/cubejs-testing-drivers/test/__snapshots__/redshift-full.test.ts.snap @@ -1797,81 +1797,6 @@ Array [ ] `; -exports[`Queries with the @cubejs-backend/redshift-driver querying BigECommerce: multi-stage group by time dimension 1`] = ` -Array [ - Object { - "BigECommerce.orderDate": "2020-01-01T00:00:00.000", - "BigECommerce.orderDate.month": "2020-01-01T00:00:00.000", - "BigECommerce.orderDate.quarter": "2020-01-01T00:00:00.000", - "BigECommerce.totalProfit": "29.65480", - "BigECommerce.totalProfitForQuarter": "619.44850", - }, - Object { - "BigECommerce.orderDate": "2020-02-01T00:00:00.000", - "BigECommerce.orderDate.month": "2020-02-01T00:00:00.000", - "BigECommerce.orderDate.quarter": "2020-01-01T00:00:00.000", - "BigECommerce.totalProfit": "6.19920", - "BigECommerce.totalProfitForQuarter": "619.44850", - }, - Object { - "BigECommerce.orderDate": "2020-03-01T00:00:00.000", - "BigECommerce.orderDate.month": "2020-03-01T00:00:00.000", - "BigECommerce.orderDate.quarter": "2020-01-01T00:00:00.000", - "BigECommerce.totalProfit": "583.59450", - "BigECommerce.totalProfitForQuarter": "619.44850", - }, - Object { - "BigECommerce.orderDate": "2020-04-01T00:00:00.000", - "BigECommerce.orderDate.month": "2020-04-01T00:00:00.000", - "BigECommerce.orderDate.quarter": "2020-04-01T00:00:00.000", - "BigECommerce.totalProfit": "6.41760", - "BigECommerce.totalProfitForQuarter": "394.33860", - }, - Object { - "BigECommerce.orderDate": "2020-05-01T00:00:00.000", - "BigECommerce.orderDate.month": "2020-05-01T00:00:00.000", - "BigECommerce.orderDate.quarter": "2020-04-01T00:00:00.000", - "BigECommerce.totalProfit": "353.68490", - "BigECommerce.totalProfitForQuarter": "394.33860", - }, - Object { - "BigECommerce.orderDate": "2020-06-01T00:00:00.000", - "BigECommerce.orderDate.month": "2020-06-01T00:00:00.000", - "BigECommerce.orderDate.quarter": "2020-04-01T00:00:00.000", - "BigECommerce.totalProfit": "34.23610", - "BigECommerce.totalProfitForQuarter": "394.33860", - }, - Object { - "BigECommerce.orderDate": "2020-09-01T00:00:00.000", - "BigECommerce.orderDate.month": "2020-09-01T00:00:00.000", - "BigECommerce.orderDate.quarter": "2020-07-01T00:00:00.000", - "BigECommerce.totalProfit": "461.13320", - "BigECommerce.totalProfitForQuarter": "461.13320", - }, - Object { - "BigECommerce.orderDate": "2020-10-01T00:00:00.000", - "BigECommerce.orderDate.month": "2020-10-01T00:00:00.000", - "BigECommerce.orderDate.quarter": "2020-10-01T00:00:00.000", - "BigECommerce.totalProfit": "139.99700", - "BigECommerce.totalProfitForQuarter": "1576.63240", - }, - Object { - "BigECommerce.orderDate": "2020-11-01T00:00:00.000", - "BigECommerce.orderDate.month": "2020-11-01T00:00:00.000", - "BigECommerce.orderDate.quarter": "2020-10-01T00:00:00.000", - "BigECommerce.totalProfit": "1132.66170", - "BigECommerce.totalProfitForQuarter": "1576.63240", - }, - Object { - "BigECommerce.orderDate": "2020-12-01T00:00:00.000", - "BigECommerce.orderDate.month": "2020-12-01T00:00:00.000", - "BigECommerce.orderDate.quarter": "2020-10-01T00:00:00.000", - "BigECommerce.totalProfit": "303.97370", - "BigECommerce.totalProfitForQuarter": "1576.63240", - }, -] -`; - exports[`Queries with the @cubejs-backend/redshift-driver SQL API: Date/time comparison with SQL push down 1`] = ` Array [ Object { @@ -11537,6 +11462,81 @@ Array [ ] `; +exports[`Queries with the @cubejs-backend/redshift-driver querying BigECommerce: multi-stage group by time dimension 1`] = ` +Array [ + Object { + "BigECommerce.orderDate": "2020-01-01T00:00:00.000", + "BigECommerce.orderDate.month": "2020-01-01T00:00:00.000", + "BigECommerce.orderDate.quarter": "2020-01-01T00:00:00.000", + "BigECommerce.totalProfit": "29.65480", + "BigECommerce.totalProfitForQuarter": "619.44850", + }, + Object { + "BigECommerce.orderDate": "2020-02-01T00:00:00.000", + "BigECommerce.orderDate.month": "2020-02-01T00:00:00.000", + "BigECommerce.orderDate.quarter": "2020-01-01T00:00:00.000", + "BigECommerce.totalProfit": "6.19920", + "BigECommerce.totalProfitForQuarter": "619.44850", + }, + Object { + "BigECommerce.orderDate": "2020-03-01T00:00:00.000", + "BigECommerce.orderDate.month": "2020-03-01T00:00:00.000", + "BigECommerce.orderDate.quarter": "2020-01-01T00:00:00.000", + "BigECommerce.totalProfit": "583.59450", + "BigECommerce.totalProfitForQuarter": "619.44850", + }, + Object { + "BigECommerce.orderDate": "2020-04-01T00:00:00.000", + "BigECommerce.orderDate.month": "2020-04-01T00:00:00.000", + "BigECommerce.orderDate.quarter": "2020-04-01T00:00:00.000", + "BigECommerce.totalProfit": "6.41760", + "BigECommerce.totalProfitForQuarter": "394.33860", + }, + Object { + "BigECommerce.orderDate": "2020-05-01T00:00:00.000", + "BigECommerce.orderDate.month": "2020-05-01T00:00:00.000", + "BigECommerce.orderDate.quarter": "2020-04-01T00:00:00.000", + "BigECommerce.totalProfit": "353.68490", + "BigECommerce.totalProfitForQuarter": "394.33860", + }, + Object { + "BigECommerce.orderDate": "2020-06-01T00:00:00.000", + "BigECommerce.orderDate.month": "2020-06-01T00:00:00.000", + "BigECommerce.orderDate.quarter": "2020-04-01T00:00:00.000", + "BigECommerce.totalProfit": "34.23610", + "BigECommerce.totalProfitForQuarter": "394.33860", + }, + Object { + "BigECommerce.orderDate": "2020-09-01T00:00:00.000", + "BigECommerce.orderDate.month": "2020-09-01T00:00:00.000", + "BigECommerce.orderDate.quarter": "2020-07-01T00:00:00.000", + "BigECommerce.totalProfit": "461.13320", + "BigECommerce.totalProfitForQuarter": "461.13320", + }, + Object { + "BigECommerce.orderDate": "2020-10-01T00:00:00.000", + "BigECommerce.orderDate.month": "2020-10-01T00:00:00.000", + "BigECommerce.orderDate.quarter": "2020-10-01T00:00:00.000", + "BigECommerce.totalProfit": "139.99700", + "BigECommerce.totalProfitForQuarter": "1576.63240", + }, + Object { + "BigECommerce.orderDate": "2020-11-01T00:00:00.000", + "BigECommerce.orderDate.month": "2020-11-01T00:00:00.000", + "BigECommerce.orderDate.quarter": "2020-10-01T00:00:00.000", + "BigECommerce.totalProfit": "1132.66170", + "BigECommerce.totalProfitForQuarter": "1576.63240", + }, + Object { + "BigECommerce.orderDate": "2020-12-01T00:00:00.000", + "BigECommerce.orderDate.month": "2020-12-01T00:00:00.000", + "BigECommerce.orderDate.quarter": "2020-10-01T00:00:00.000", + "BigECommerce.totalProfit": "303.97370", + "BigECommerce.totalProfitForQuarter": "1576.63240", + }, +] +`; + exports[`Queries with the @cubejs-backend/redshift-driver querying BigECommerce: null boolean 1`] = ` Array [ Object { @@ -17569,6 +17569,111 @@ Array [ ] `; +exports[`Queries with the @cubejs-backend/redshift-driver querying SwitchSourceTest: filter by switch dimensions 1`] = ` +Array [ + Object { + "SwitchSourceTest.city": "Detroit", + "SwitchSourceTest.orderDate": "2020-01-01T00:00:00.000", + "SwitchSourceTest.orderDate.month": "2020-01-01T00:00:00.000", + "SwitchSourceTest.totalSales": "210.98000", + }, + Object { + "SwitchSourceTest.city": "Lorain", + "SwitchSourceTest.orderDate": "2020-01-01T00:00:00.000", + "SwitchSourceTest.orderDate.month": "2020-01-01T00:00:00.000", + "SwitchSourceTest.totalSales": "48.89600", + }, + Object { + "SwitchSourceTest.city": "Decatur", + "SwitchSourceTest.orderDate": "2020-02-01T00:00:00.000", + "SwitchSourceTest.orderDate.month": "2020-02-01T00:00:00.000", + "SwitchSourceTest.totalSales": "18.36800", + }, + Object { + "SwitchSourceTest.city": "Houston", + "SwitchSourceTest.orderDate": "2020-03-01T00:00:00.000", + "SwitchSourceTest.orderDate.month": "2020-03-01T00:00:00.000", + "SwitchSourceTest.totalSales": "2399.96000", + }, + Object { + "SwitchSourceTest.city": "New York City", + "SwitchSourceTest.orderDate": "2020-03-01T00:00:00.000", + "SwitchSourceTest.orderDate.month": "2020-03-01T00:00:00.000", + "SwitchSourceTest.totalSales": "71.60000", + }, +] +`; + +exports[`Queries with the @cubejs-backend/redshift-driver querying SwitchSourceTest: full cross join 1`] = ` +Array [ + Object { + "SwitchSourceTest.city": "Detroit", + "SwitchSourceTest.orderDate": "2020-01-01T00:00:00.000", + "SwitchSourceTest.orderDate.month": "2020-01-01T00:00:00.000", + "SwitchSourceTest.totalSales": "1265.88000", + }, + Object { + "SwitchSourceTest.city": "Lorain", + "SwitchSourceTest.orderDate": "2020-01-01T00:00:00.000", + "SwitchSourceTest.orderDate.month": "2020-01-01T00:00:00.000", + "SwitchSourceTest.totalSales": "293.37600", + }, + Object { + "SwitchSourceTest.city": "Decatur", + "SwitchSourceTest.orderDate": "2020-02-01T00:00:00.000", + "SwitchSourceTest.orderDate.month": "2020-02-01T00:00:00.000", + "SwitchSourceTest.totalSales": "110.20800", + }, + Object { + "SwitchSourceTest.city": "Houston", + "SwitchSourceTest.orderDate": "2020-03-01T00:00:00.000", + "SwitchSourceTest.orderDate.month": "2020-03-01T00:00:00.000", + "SwitchSourceTest.totalSales": "14399.76000", + }, + Object { + "SwitchSourceTest.city": "New York City", + "SwitchSourceTest.orderDate": "2020-03-01T00:00:00.000", + "SwitchSourceTest.orderDate.month": "2020-03-01T00:00:00.000", + "SwitchSourceTest.totalSales": "429.60000", + }, +] +`; + +exports[`Queries with the @cubejs-backend/redshift-driver querying SwitchSourceTest: simple cross join 1`] = ` +Array [ + Object { + "SwitchSourceTest.city": "Detroit", + "SwitchSourceTest.orderDate": "2020-01-01T00:00:00.000", + "SwitchSourceTest.orderDate.month": "2020-01-01T00:00:00.000", + "SwitchSourceTest.totalSalesA": "421.96000", + }, + Object { + "SwitchSourceTest.city": "Lorain", + "SwitchSourceTest.orderDate": "2020-01-01T00:00:00.000", + "SwitchSourceTest.orderDate.month": "2020-01-01T00:00:00.000", + "SwitchSourceTest.totalSalesA": "97.79200", + }, + Object { + "SwitchSourceTest.city": "Decatur", + "SwitchSourceTest.orderDate": "2020-02-01T00:00:00.000", + "SwitchSourceTest.orderDate.month": "2020-02-01T00:00:00.000", + "SwitchSourceTest.totalSalesA": "36.73600", + }, + Object { + "SwitchSourceTest.city": "Houston", + "SwitchSourceTest.orderDate": "2020-03-01T00:00:00.000", + "SwitchSourceTest.orderDate.month": "2020-03-01T00:00:00.000", + "SwitchSourceTest.totalSalesA": "4799.92000", + }, + Object { + "SwitchSourceTest.city": "New York City", + "SwitchSourceTest.orderDate": "2020-03-01T00:00:00.000", + "SwitchSourceTest.orderDate.month": "2020-03-01T00:00:00.000", + "SwitchSourceTest.totalSalesA": "143.20000", + }, +] +`; + exports[`Queries with the @cubejs-backend/redshift-driver querying custom granularities (with preaggregation) ECommerce: totalQuantity by half_year + dimension 1`] = ` Array [ Object { diff --git a/packages/cubejs-testing-drivers/test/__snapshots__/snowflake-full.test.ts.snap b/packages/cubejs-testing-drivers/test/__snapshots__/snowflake-full.test.ts.snap index 80eeb0bd555d9..3efb46d64eaf4 100644 --- a/packages/cubejs-testing-drivers/test/__snapshots__/snowflake-full.test.ts.snap +++ b/packages/cubejs-testing-drivers/test/__snapshots__/snowflake-full.test.ts.snap @@ -17959,6 +17959,111 @@ Array [ ] `; +exports[`Queries with the @cubejs-backend/snowflake-driver querying SwitchSourceTest: filter by switch dimensions 1`] = ` +Array [ + Object { + "SwitchSourceTest.city": "Detroit", + "SwitchSourceTest.orderDate": "2020-01-01T00:00:00.000", + "SwitchSourceTest.orderDate.month": "2020-01-01T00:00:00.000", + "SwitchSourceTest.totalSales": "210.980", + }, + Object { + "SwitchSourceTest.city": "Lorain", + "SwitchSourceTest.orderDate": "2020-01-01T00:00:00.000", + "SwitchSourceTest.orderDate.month": "2020-01-01T00:00:00.000", + "SwitchSourceTest.totalSales": "48.896", + }, + Object { + "SwitchSourceTest.city": "Decatur", + "SwitchSourceTest.orderDate": "2020-02-01T00:00:00.000", + "SwitchSourceTest.orderDate.month": "2020-02-01T00:00:00.000", + "SwitchSourceTest.totalSales": "18.368", + }, + Object { + "SwitchSourceTest.city": "Houston", + "SwitchSourceTest.orderDate": "2020-03-01T00:00:00.000", + "SwitchSourceTest.orderDate.month": "2020-03-01T00:00:00.000", + "SwitchSourceTest.totalSales": "2399.960", + }, + Object { + "SwitchSourceTest.city": "New York City", + "SwitchSourceTest.orderDate": "2020-03-01T00:00:00.000", + "SwitchSourceTest.orderDate.month": "2020-03-01T00:00:00.000", + "SwitchSourceTest.totalSales": "71.600", + }, +] +`; + +exports[`Queries with the @cubejs-backend/snowflake-driver querying SwitchSourceTest: full cross join 1`] = ` +Array [ + Object { + "SwitchSourceTest.city": "Detroit", + "SwitchSourceTest.orderDate": "2020-01-01T00:00:00.000", + "SwitchSourceTest.orderDate.month": "2020-01-01T00:00:00.000", + "SwitchSourceTest.totalSales": "1265.880", + }, + Object { + "SwitchSourceTest.city": "Lorain", + "SwitchSourceTest.orderDate": "2020-01-01T00:00:00.000", + "SwitchSourceTest.orderDate.month": "2020-01-01T00:00:00.000", + "SwitchSourceTest.totalSales": "293.376", + }, + Object { + "SwitchSourceTest.city": "Decatur", + "SwitchSourceTest.orderDate": "2020-02-01T00:00:00.000", + "SwitchSourceTest.orderDate.month": "2020-02-01T00:00:00.000", + "SwitchSourceTest.totalSales": "110.208", + }, + Object { + "SwitchSourceTest.city": "Houston", + "SwitchSourceTest.orderDate": "2020-03-01T00:00:00.000", + "SwitchSourceTest.orderDate.month": "2020-03-01T00:00:00.000", + "SwitchSourceTest.totalSales": "14399.760", + }, + Object { + "SwitchSourceTest.city": "New York City", + "SwitchSourceTest.orderDate": "2020-03-01T00:00:00.000", + "SwitchSourceTest.orderDate.month": "2020-03-01T00:00:00.000", + "SwitchSourceTest.totalSales": "429.600", + }, +] +`; + +exports[`Queries with the @cubejs-backend/snowflake-driver querying SwitchSourceTest: simple cross join 1`] = ` +Array [ + Object { + "SwitchSourceTest.city": "Detroit", + "SwitchSourceTest.orderDate": "2020-01-01T00:00:00.000", + "SwitchSourceTest.orderDate.month": "2020-01-01T00:00:00.000", + "SwitchSourceTest.totalSalesA": "421.960", + }, + Object { + "SwitchSourceTest.city": "Lorain", + "SwitchSourceTest.orderDate": "2020-01-01T00:00:00.000", + "SwitchSourceTest.orderDate.month": "2020-01-01T00:00:00.000", + "SwitchSourceTest.totalSalesA": "97.792", + }, + Object { + "SwitchSourceTest.city": "Decatur", + "SwitchSourceTest.orderDate": "2020-02-01T00:00:00.000", + "SwitchSourceTest.orderDate.month": "2020-02-01T00:00:00.000", + "SwitchSourceTest.totalSalesA": "36.736", + }, + Object { + "SwitchSourceTest.city": "Houston", + "SwitchSourceTest.orderDate": "2020-03-01T00:00:00.000", + "SwitchSourceTest.orderDate.month": "2020-03-01T00:00:00.000", + "SwitchSourceTest.totalSalesA": "4799.920", + }, + Object { + "SwitchSourceTest.city": "New York City", + "SwitchSourceTest.orderDate": "2020-03-01T00:00:00.000", + "SwitchSourceTest.orderDate.month": "2020-03-01T00:00:00.000", + "SwitchSourceTest.totalSalesA": "143.200", + }, +] +`; + exports[`Queries with the @cubejs-backend/snowflake-driver querying custom granularities (with preaggregation) ECommerce: totalQuantity by half_year + dimension 1`] = ` Array [ Object { diff --git a/rust/cubesqlplanner/.gitignore b/rust/cubesqlplanner/.gitignore index fb75eef2592d8..8358b651bb0c0 100644 --- a/rust/cubesqlplanner/.gitignore +++ b/rust/cubesqlplanner/.gitignore @@ -11,3 +11,5 @@ node_modules /cubesql/egraph-debug-intermediate egraph-debug /cubesql/debug-qtrace +.claude +CLAUDE.md diff --git a/rust/cubesqlplanner/Cargo.lock b/rust/cubesqlplanner/Cargo.lock index 024ad1253d50c..8d58eb1019ab2 100644 --- a/rust/cubesqlplanner/Cargo.lock +++ b/rust/cubesqlplanner/Cargo.lock @@ -725,6 +725,7 @@ dependencies = [ "serde", "serde_json", "tokio", + "typed-builder", ] [[package]] @@ -3189,6 +3190,26 @@ version = "0.2.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e421abadd41a4225275504ea4d6566923418b7f05506fbc9c0fe86ba7396114b" +[[package]] +name = "typed-builder" +version = "0.21.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fef81aec2ca29576f9f6ae8755108640d0a86dd3161b2e8bca6cfa554e98f77d" +dependencies = [ + "typed-builder-macro", +] + +[[package]] +name = "typed-builder-macro" +version = "0.21.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1ecb9ecf7799210407c14a8cfdfe0173365780968dc57973ed082211958e0b18" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.98", +] + [[package]] name = "typenum" version = "1.17.0" diff --git a/rust/cubesqlplanner/cubesqlplanner/Cargo.toml b/rust/cubesqlplanner/cubesqlplanner/Cargo.toml index 260ad6131a729..bf06699756180 100644 --- a/rust/cubesqlplanner/cubesqlplanner/Cargo.toml +++ b/rust/cubesqlplanner/cubesqlplanner/Cargo.toml @@ -20,6 +20,7 @@ chrono = "0.4.15" chrono-tz = "0.8.2" lazy_static = "1.4.0" regex = "1.3.9" +typed-builder = "0.21.2" [dependencies.neon] version = "=1" diff --git a/rust/cubesqlplanner/cubesqlplanner/src/cube_bridge/case_else_item.rs b/rust/cubesqlplanner/cubesqlplanner/src/cube_bridge/case_else_item.rs index 250dbd135479c..8dacb0f549b55 100644 --- a/rust/cubesqlplanner/cubesqlplanner/src/cube_bridge/case_else_item.rs +++ b/rust/cubesqlplanner/cubesqlplanner/src/cube_bridge/case_else_item.rs @@ -1,4 +1,4 @@ -use super::case_label::CaseLabel; +use super::string_or_sql::StringOrSql; use cubenativeutils::wrappers::serializer::{ NativeDeserialize, NativeDeserializer, NativeSerialize, }; @@ -11,5 +11,5 @@ use std::rc::Rc; #[nativebridge::native_bridge] pub trait CaseElseItem { #[nbridge(field)] - fn label(&self) -> Result; + fn label(&self) -> Result; } diff --git a/rust/cubesqlplanner/cubesqlplanner/src/cube_bridge/case_item.rs b/rust/cubesqlplanner/cubesqlplanner/src/cube_bridge/case_item.rs index 2d6d4865cace5..4d6280b00f7f3 100644 --- a/rust/cubesqlplanner/cubesqlplanner/src/cube_bridge/case_item.rs +++ b/rust/cubesqlplanner/cubesqlplanner/src/cube_bridge/case_item.rs @@ -1,5 +1,5 @@ -use super::case_label::CaseLabel; use super::member_sql::{MemberSql, NativeMemberSql}; +use super::string_or_sql::StringOrSql; use cubenativeutils::wrappers::serializer::{ NativeDeserialize, NativeDeserializer, NativeSerialize, }; @@ -14,5 +14,5 @@ pub trait CaseItem { #[nbridge(field)] fn sql(&self) -> Result, CubeError>; #[nbridge(field)] - fn label(&self) -> Result; + fn label(&self) -> Result; } diff --git a/rust/cubesqlplanner/cubesqlplanner/src/cube_bridge/case_switch_definition.rs b/rust/cubesqlplanner/cubesqlplanner/src/cube_bridge/case_switch_definition.rs new file mode 100644 index 0000000000000..69b44d62c290a --- /dev/null +++ b/rust/cubesqlplanner/cubesqlplanner/src/cube_bridge/case_switch_definition.rs @@ -0,0 +1,23 @@ +use crate::cube_bridge::member_sql::{MemberSql, NativeMemberSql}; + +use super::case_switch_else_item::{CaseSwitchElseItem, NativeCaseSwitchElseItem}; +use super::case_switch_item::{CaseSwitchItem, NativeCaseSwitchItem}; +use cubenativeutils::wrappers::serializer::{ + NativeDeserialize, NativeDeserializer, NativeSerialize, +}; +use cubenativeutils::wrappers::NativeArray; +use cubenativeutils::wrappers::NativeContextHolder; +use cubenativeutils::wrappers::NativeObjectHandle; +use cubenativeutils::CubeError; +use std::any::Any; +use std::rc::Rc; + +#[nativebridge::native_bridge] +pub trait CaseSwitchDefinition { + #[nbridge(field)] + fn switch(&self) -> Result, CubeError>; + #[nbridge(field, vec)] + fn when(&self) -> Result>, CubeError>; + #[nbridge(field, rename = "else")] + fn else_sql(&self) -> Result, CubeError>; +} diff --git a/rust/cubesqlplanner/cubesqlplanner/src/cube_bridge/case_switch_else_item.rs b/rust/cubesqlplanner/cubesqlplanner/src/cube_bridge/case_switch_else_item.rs new file mode 100644 index 0000000000000..1c1131714e032 --- /dev/null +++ b/rust/cubesqlplanner/cubesqlplanner/src/cube_bridge/case_switch_else_item.rs @@ -0,0 +1,16 @@ +use crate::cube_bridge::member_sql::{MemberSql, NativeMemberSql}; + +use cubenativeutils::wrappers::serializer::{ + NativeDeserialize, NativeDeserializer, NativeSerialize, +}; +use cubenativeutils::wrappers::NativeContextHolder; +use cubenativeutils::wrappers::NativeObjectHandle; +use cubenativeutils::CubeError; +use std::any::Any; +use std::rc::Rc; + +#[nativebridge::native_bridge] +pub trait CaseSwitchElseItem { + #[nbridge(field)] + fn sql(&self) -> Result, CubeError>; +} diff --git a/rust/cubesqlplanner/cubesqlplanner/src/cube_bridge/case_switch_item.rs b/rust/cubesqlplanner/cubesqlplanner/src/cube_bridge/case_switch_item.rs new file mode 100644 index 0000000000000..95406dad4444f --- /dev/null +++ b/rust/cubesqlplanner/cubesqlplanner/src/cube_bridge/case_switch_item.rs @@ -0,0 +1,21 @@ +use super::member_sql::{MemberSql, NativeMemberSql}; +use cubenativeutils::wrappers::serializer::{ + NativeDeserialize, NativeDeserializer, NativeSerialize, +}; +use cubenativeutils::wrappers::NativeContextHolder; +use cubenativeutils::wrappers::NativeObjectHandle; +use cubenativeutils::CubeError; +use serde::{Deserialize, Serialize}; +use std::any::Any; +use std::rc::Rc; + +#[derive(Serialize, Deserialize, Debug)] +pub struct CaseSwitchItemStatic { + pub value: String, +} + +#[nativebridge::native_bridge(CaseSwitchItemStatic)] +pub trait CaseSwitchItem { + #[nbridge(field)] + fn sql(&self) -> Result, CubeError>; +} diff --git a/rust/cubesqlplanner/cubesqlplanner/src/cube_bridge/case_variant.rs b/rust/cubesqlplanner/cubesqlplanner/src/cube_bridge/case_variant.rs new file mode 100644 index 0000000000000..710646aaea4d3 --- /dev/null +++ b/rust/cubesqlplanner/cubesqlplanner/src/cube_bridge/case_variant.rs @@ -0,0 +1,28 @@ +use crate::cube_bridge::case_definition::{CaseDefinition, NativeCaseDefinition}; +use crate::cube_bridge::case_switch_definition::{ + CaseSwitchDefinition, NativeCaseSwitchDefinition, +}; + +use cubenativeutils::wrappers::inner_types::InnerTypes; +use cubenativeutils::wrappers::serializer::NativeDeserialize; +use cubenativeutils::wrappers::NativeObjectHandle; +use cubenativeutils::CubeError; +use std::rc::Rc; + +pub enum CaseVariant { + Case(Rc), + CaseSwitch(Rc), +} + +impl NativeDeserialize for CaseVariant { + fn from_native(native_object: NativeObjectHandle) -> Result { + let res = match NativeCaseSwitchDefinition::from_native(native_object.clone()) { + Ok(case) => Ok(Self::CaseSwitch(Rc::new(case))), + Err(_) => match NativeCaseDefinition::from_native(native_object) { + Ok(case) => Ok(Self::Case(Rc::new(case))), + Err(_) => Err(CubeError::user(format!("Case or Case Switch expected"))), + }, + }; + res + } +} diff --git a/rust/cubesqlplanner/cubesqlplanner/src/cube_bridge/dimension_definition.rs b/rust/cubesqlplanner/cubesqlplanner/src/cube_bridge/dimension_definition.rs index 4765e8b6eba3b..7706f95455705 100644 --- a/rust/cubesqlplanner/cubesqlplanner/src/cube_bridge/dimension_definition.rs +++ b/rust/cubesqlplanner/cubesqlplanner/src/cube_bridge/dimension_definition.rs @@ -1,4 +1,4 @@ -use super::case_definition::{CaseDefinition, NativeCaseDefinition}; +use super::case_variant::CaseVariant; use super::geo_item::{GeoItem, NativeGeoItem}; use super::member_sql::{MemberSql, NativeMemberSql}; use crate::cube_bridge::timeshift_definition::{NativeTimeShiftDefinition, TimeShiftDefinition}; @@ -25,6 +25,7 @@ pub struct DimensionDefinitionStatic { pub sub_query: Option, #[serde(rename = "propagateFiltersToSubQuery")] pub propagate_filters_to_sub_query: Option, + pub values: Option>, } #[nativebridge::native_bridge(DimensionDefinitionStatic)] @@ -33,7 +34,7 @@ pub trait DimensionDefinition { fn sql(&self) -> Result>, CubeError>; #[nbridge(field, optional)] - fn case(&self) -> Result>, CubeError>; + fn case(&self) -> Result, CubeError>; #[nbridge(field, optional)] fn latitude(&self) -> Result>, CubeError>; diff --git a/rust/cubesqlplanner/cubesqlplanner/src/cube_bridge/measure_definition.rs b/rust/cubesqlplanner/cubesqlplanner/src/cube_bridge/measure_definition.rs index bc0e581ee01d8..fe5c352b7cfd2 100644 --- a/rust/cubesqlplanner/cubesqlplanner/src/cube_bridge/measure_definition.rs +++ b/rust/cubesqlplanner/cubesqlplanner/src/cube_bridge/measure_definition.rs @@ -1,4 +1,4 @@ -use super::cube_definition::{CubeDefinition, NativeCubeDefinition}; +use super::case_variant::CaseVariant; use super::member_order_by::{MemberOrderBy, NativeMemberOrderBy}; use super::member_sql::{MemberSql, NativeMemberSql}; use super::struct_with_sql_member::{NativeStructWithSqlMember, StructWithSqlMember}; @@ -58,7 +58,8 @@ pub trait MeasureDefinition { #[nbridge(field, optional)] fn sql(&self) -> Result>, CubeError>; - fn cube(&self) -> Result, CubeError>; + #[nbridge(field, optional)] + fn case(&self) -> Result, CubeError>; #[nbridge(field, optional, vec)] fn filters(&self) -> Result>>, CubeError>; diff --git a/rust/cubesqlplanner/cubesqlplanner/src/cube_bridge/mod.rs b/rust/cubesqlplanner/cubesqlplanner/src/cube_bridge/mod.rs index 69286f9c1a44b..83b2657850e2f 100644 --- a/rust/cubesqlplanner/cubesqlplanner/src/cube_bridge/mod.rs +++ b/rust/cubesqlplanner/cubesqlplanner/src/cube_bridge/mod.rs @@ -3,7 +3,10 @@ pub mod base_tools; pub mod case_definition; pub mod case_else_item; pub mod case_item; -pub mod case_label; +pub mod case_switch_definition; +pub mod case_switch_else_item; +pub mod case_switch_item; +pub mod case_variant; pub mod cube_definition; pub mod dimension_definition; pub mod driver_tools; @@ -29,5 +32,6 @@ pub mod security_context; pub mod segment_definition; pub mod sql_templates_render; pub mod sql_utils; +pub mod string_or_sql; pub mod struct_with_sql_member; pub mod timeshift_definition; diff --git a/rust/cubesqlplanner/cubesqlplanner/src/cube_bridge/case_label.rs b/rust/cubesqlplanner/cubesqlplanner/src/cube_bridge/string_or_sql.rs similarity index 91% rename from rust/cubesqlplanner/cubesqlplanner/src/cube_bridge/case_label.rs rename to rust/cubesqlplanner/cubesqlplanner/src/cube_bridge/string_or_sql.rs index 6f9d8fafb1ecf..0bbd10fe24dd4 100644 --- a/rust/cubesqlplanner/cubesqlplanner/src/cube_bridge/case_label.rs +++ b/rust/cubesqlplanner/cubesqlplanner/src/cube_bridge/string_or_sql.rs @@ -5,12 +5,12 @@ use cubenativeutils::wrappers::NativeObjectHandle; use cubenativeutils::CubeError; use std::rc::Rc; -pub enum CaseLabel { +pub enum StringOrSql { String(String), MemberSql(Rc), } -impl NativeDeserialize for CaseLabel { +impl NativeDeserialize for StringOrSql { fn from_native(native_object: NativeObjectHandle) -> Result { match String::from_native(native_object.clone()) { Ok(label) => Ok(Self::String(label)), diff --git a/rust/cubesqlplanner/cubesqlplanner/src/logical_plan/aggregate_multiplied_subquery.rs b/rust/cubesqlplanner/cubesqlplanner/src/logical_plan/aggregate_multiplied_subquery.rs index f609f84558165..aea9c92a8a21f 100644 --- a/rust/cubesqlplanner/cubesqlplanner/src/logical_plan/aggregate_multiplied_subquery.rs +++ b/rust/cubesqlplanner/cubesqlplanner/src/logical_plan/aggregate_multiplied_subquery.rs @@ -3,30 +3,12 @@ use super::*; use cubenativeutils::CubeError; use std::rc::Rc; -pub enum AggregateMultipliedSubquerySouce { - Cube(Rc), - MeasureSubquery(Rc), -} - -impl AggregateMultipliedSubquerySouce { - fn as_plan_node(&self) -> PlanNode { - match self { - Self::Cube(item) => item.as_plan_node(), - Self::MeasureSubquery(item) => item.as_plan_node(), - } - } - fn with_plan_node(&self, plan_node: PlanNode) -> Result { - Ok(match self { - Self::Cube(_) => Self::Cube(plan_node.into_logical_node()?), - Self::MeasureSubquery(_) => Self::MeasureSubquery(plan_node.into_logical_node()?), - }) - } -} +logical_source_enum!(AggregateMultipliedSubquerySource, [Cube, MeasureSubquery]); pub struct AggregateMultipliedSubquery { pub schema: Rc, pub keys_subquery: Rc, - pub source: AggregateMultipliedSubquerySouce, + pub source: AggregateMultipliedSubquerySource, pub dimension_subqueries: Vec>, } @@ -127,16 +109,7 @@ impl PrettyPrint for AggregateMultipliedSubquery { result.println("keys_subquery:", &state); self.keys_subquery.pretty_print(result, &details_state); result.println("source:", &state); - match &self.source { - AggregateMultipliedSubquerySouce::Cube(cube) => { - result.println("Cube:", &details_state); - cube.pretty_print(result, &details_state.new_level()); - } - AggregateMultipliedSubquerySouce::MeasureSubquery(measure_subquery) => { - result.println(&format!("MeasureSubquery: "), &details_state); - measure_subquery.pretty_print(result, &details_state); - } - } + self.source.pretty_print(result, &details_state); if !self.dimension_subqueries.is_empty() { result.println("dimension_subqueries:", &state); let details_state = state.new_level(); diff --git a/rust/cubesqlplanner/cubesqlplanner/src/logical_plan/calc_groups_cross_join.rs b/rust/cubesqlplanner/cubesqlplanner/src/logical_plan/calc_groups_cross_join.rs new file mode 100644 index 0000000000000..1e2ac749ae917 --- /dev/null +++ b/rust/cubesqlplanner/cubesqlplanner/src/logical_plan/calc_groups_cross_join.rs @@ -0,0 +1,85 @@ +use crate::planner::sql_evaluator::MemberSymbol; + +use super::*; +use cubenativeutils::CubeError; +use std::rc::Rc; +use typed_builder::TypedBuilder; + +#[derive(Clone)] +pub struct CalcGroupDescription { + pub symbol: Rc, + pub values: Vec, +} + +impl PrettyPrint for CalcGroupDescription { + fn pretty_print(&self, result: &mut PrettyPrintResult, state: &PrettyPrintState) { + let state = state.new_level(); + result.println( + &format!("{}:{}", self.symbol.full_name(), self.values.join(", ")), + &state, + ); + } +} + +#[derive(Clone, TypedBuilder)] +pub struct CalcGroupsCrossJoin { + source: BaseQuerySource, + calc_groups: Vec>, +} + +impl CalcGroupsCrossJoin { + pub fn source(&self) -> &BaseQuerySource { + &self.source + } + + pub fn calc_groups(&self) -> &Vec> { + &self.calc_groups + } +} + +impl LogicalNode for CalcGroupsCrossJoin { + fn as_plan_node(self: &Rc) -> PlanNode { + PlanNode::CalcGroupsCrossJoin(self.clone()) + } + + fn inputs(&self) -> Vec { + vec![self.source.as_plan_node()] + } + + fn with_inputs(self: Rc, inputs: Vec) -> Result, CubeError> { + check_inputs_len(&inputs, 1, self.node_name())?; + let source = &inputs[0]; + + Ok(Rc::new(Self { + calc_groups: self.calc_groups.clone(), + source: self.source.with_plan_node(source.clone())?, + })) + } + + fn node_name(&self) -> &'static str { + "CalcGroupsCrossJoin" + } + + fn try_from_plan_node(plan_node: PlanNode) -> Result, CubeError> { + if let PlanNode::CalcGroupsCrossJoin(item) = plan_node { + Ok(item) + } else { + Err(cast_error(&plan_node, "MultiStageGetDateRange")) + } + } +} + +impl PrettyPrint for CalcGroupsCrossJoin { + fn pretty_print(&self, result: &mut PrettyPrintResult, state: &PrettyPrintState) { + let state = state.new_level(); + result.println("CaclGroupsCrossJoin: ", &state); + let state = state.new_level(); + result.println("Groups: ", &state); + let details_state = state.new_level(); + for group in &self.calc_groups { + group.pretty_print(result, &details_state); + } + result.println("Source: ", &state); + self.source.pretty_print(result, &details_state); + } +} diff --git a/rust/cubesqlplanner/cubesqlplanner/src/logical_plan/cube.rs b/rust/cubesqlplanner/cubesqlplanner/src/logical_plan/cube.rs index cd78e7f1c4685..746423d404626 100644 --- a/rust/cubesqlplanner/cubesqlplanner/src/logical_plan/cube.rs +++ b/rust/cubesqlplanner/cubesqlplanner/src/logical_plan/cube.rs @@ -2,29 +2,53 @@ use super::*; use crate::planner::BaseCube; use cubenativeutils::CubeError; use std::rc::Rc; +use typed_builder::TypedBuilder; -#[derive(Clone)] +#[derive(Clone, TypedBuilder)] pub struct OriginalSqlPreAggregation { - pub name: String, + name: String, +} + +impl OriginalSqlPreAggregation { + pub fn name(&self) -> &String { + &self.name + } } impl PrettyPrint for OriginalSqlPreAggregation { fn pretty_print(&self, result: &mut PrettyPrintResult, state: &PrettyPrintState) { - result.println(&format!("OriginalSqlPreAggregation: {}", self.name), state); + result.println( + &format!("OriginalSqlPreAggregation: {}", self.name()), + state, + ); } } -#[derive(Clone)] +#[derive(Clone, TypedBuilder)] pub struct Cube { - pub name: String, - pub cube: Rc, - pub original_sql_pre_aggregation: Option, + cube: Rc, + #[builder(default)] + original_sql_pre_aggregation: Option, +} + +impl Cube { + pub fn name(&self) -> &String { + &self.cube.name() + } + + pub fn cube(&self) -> &Rc { + &self.cube + } + + pub fn original_sql_pre_aggregation(&self) -> &Option { + &self.original_sql_pre_aggregation + } } impl PrettyPrint for Cube { fn pretty_print(&self, result: &mut PrettyPrintResult, state: &PrettyPrintState) { - result.println(&format!("Cube: {}", self.name), state); - if let Some(original_sql_pre_aggregation) = &self.original_sql_pre_aggregation { + result.println(&format!("Cube: {}", self.name()), state); + if let Some(original_sql_pre_aggregation) = self.original_sql_pre_aggregation() { original_sql_pre_aggregation.pretty_print(result, state); } } @@ -32,22 +56,19 @@ impl PrettyPrint for Cube { impl Cube { pub fn new(cube: Rc) -> Rc { - Rc::new(Self { - name: cube.name().clone(), - cube, - original_sql_pre_aggregation: None, - }) + Rc::new(Self::builder().cube(cube).build()) } pub fn with_original_sql_pre_aggregation( self: Rc, original_sql_pre_aggregation: OriginalSqlPreAggregation, ) -> Rc { - Rc::new(Self { - name: self.name.clone(), - cube: self.cube.clone(), - original_sql_pre_aggregation: Some(original_sql_pre_aggregation), - }) + Rc::new( + Self::builder() + .cube(self.cube().clone()) + .original_sql_pre_aggregation(Some(original_sql_pre_aggregation)) + .build(), + ) } } diff --git a/rust/cubesqlplanner/cubesqlplanner/src/logical_plan/filter.rs b/rust/cubesqlplanner/cubesqlplanner/src/logical_plan/filter.rs index 603f6c4100f21..5a4fd2c8a85e7 100644 --- a/rust/cubesqlplanner/cubesqlplanner/src/logical_plan/filter.rs +++ b/rust/cubesqlplanner/cubesqlplanner/src/logical_plan/filter.rs @@ -2,6 +2,7 @@ use super::pretty_print::*; use crate::plan::{Filter, FilterItem}; use itertools::Itertools; +#[derive(Default)] pub struct LogicalFilter { pub dimensions_filters: Vec, pub time_dimensions_filters: Vec, diff --git a/rust/cubesqlplanner/cubesqlplanner/src/logical_plan/full_key_aggregate.rs b/rust/cubesqlplanner/cubesqlplanner/src/logical_plan/full_key_aggregate.rs index ee916e01763a0..b304388a96ab5 100644 --- a/rust/cubesqlplanner/cubesqlplanner/src/logical_plan/full_key_aggregate.rs +++ b/rust/cubesqlplanner/cubesqlplanner/src/logical_plan/full_key_aggregate.rs @@ -2,18 +2,31 @@ use super::*; use crate::planner::sql_evaluator::MemberSymbol; use cubenativeutils::CubeError; use std::rc::Rc; +use typed_builder::TypedBuilder; +#[derive(TypedBuilder)] pub struct MultiStageSubqueryRef { - pub name: String, - pub symbols: Vec>, + name: String, + #[builder(default)] + symbols: Vec>, +} + +impl MultiStageSubqueryRef { + pub fn name(&self) -> &String { + &self.name + } + + pub fn symbols(&self) -> &Vec> { + &self.symbols + } } impl PrettyPrint for MultiStageSubqueryRef { fn pretty_print(&self, result: &mut PrettyPrintResult, state: &PrettyPrintState) { - result.println(&format!("MultiStageSubqueryRef: {}", self.name), state); + result.println(&format!("MultiStageSubqueryRef: {}", self.name()), state); let state = state.new_level(); result.println( - &format!("symbols: {}", print_symbols(&self.symbols)), + &format!("symbols: {}", print_symbols(self.symbols())), &state, ); } @@ -31,7 +44,9 @@ impl ResolvedMultipliedMeasures { ResolvedMultipliedMeasures::ResolveMultipliedMeasures(resolve_multiplied_measures) => { resolve_multiplied_measures.schema.clone() } - ResolvedMultipliedMeasures::PreAggregation(simple_query) => simple_query.schema.clone(), + ResolvedMultipliedMeasures::PreAggregation(simple_query) => { + simple_query.schema().clone() + } } } } @@ -50,12 +65,32 @@ impl PrettyPrint for ResolvedMultipliedMeasures { } } -#[derive(Clone)] +#[derive(Clone, TypedBuilder)] pub struct FullKeyAggregate { - pub schema: Rc, - pub use_full_join_and_coalesce: bool, - pub multiplied_measures_resolver: Option, - pub multi_stage_subquery_refs: Vec>, + schema: Rc, + use_full_join_and_coalesce: bool, + #[builder(default)] + multiplied_measures_resolver: Option, + #[builder(default)] + multi_stage_subquery_refs: Vec>, +} + +impl FullKeyAggregate { + pub fn schema(&self) -> &Rc { + &self.schema + } + + pub fn use_full_join_and_coalesce(&self) -> bool { + self.use_full_join_and_coalesce + } + + pub fn multiplied_measures_resolver(&self) -> &Option { + &self.multiplied_measures_resolver + } + + pub fn multi_stage_subquery_refs(&self) -> &Vec> { + &self.multi_stage_subquery_refs + } } impl LogicalNode for FullKeyAggregate { @@ -64,7 +99,7 @@ impl LogicalNode for FullKeyAggregate { } fn inputs(&self) -> Vec { - if let Some(resolver) = &self.multiplied_measures_resolver { + if let Some(resolver) = self.multiplied_measures_resolver() { vec![match resolver { ResolvedMultipliedMeasures::ResolveMultipliedMeasures(item) => item.as_plan_node(), ResolvedMultipliedMeasures::PreAggregation(item) => item.as_plan_node(), @@ -75,33 +110,37 @@ impl LogicalNode for FullKeyAggregate { } fn with_inputs(self: Rc, inputs: Vec) -> Result, CubeError> { - let multiplied_measures_resolver = if self.multiplied_measures_resolver.is_none() { + let multiplied_measures_resolver = if self.multiplied_measures_resolver().is_none() { check_inputs_len(&inputs, 0, self.node_name())?; None } else { check_inputs_len(&inputs, 1, self.node_name())?; let input_source = &inputs[0]; - Some(match self.multiplied_measures_resolver.as_ref().unwrap() { - ResolvedMultipliedMeasures::ResolveMultipliedMeasures(_) => { - ResolvedMultipliedMeasures::ResolveMultipliedMeasures( - input_source.clone().into_logical_node()?, - ) - } - ResolvedMultipliedMeasures::PreAggregation(_) => { - ResolvedMultipliedMeasures::PreAggregation( - input_source.clone().into_logical_node()?, - ) - } - }) + Some( + match self.multiplied_measures_resolver().as_ref().unwrap() { + ResolvedMultipliedMeasures::ResolveMultipliedMeasures(_) => { + ResolvedMultipliedMeasures::ResolveMultipliedMeasures( + input_source.clone().into_logical_node()?, + ) + } + ResolvedMultipliedMeasures::PreAggregation(_) => { + ResolvedMultipliedMeasures::PreAggregation( + input_source.clone().into_logical_node()?, + ) + } + }, + ) }; - Ok(Rc::new(Self { - schema: self.schema.clone(), - use_full_join_and_coalesce: self.use_full_join_and_coalesce, - multiplied_measures_resolver, - multi_stage_subquery_refs: self.multi_stage_subquery_refs.clone(), - })) + Ok(Rc::new( + Self::builder() + .schema(self.schema().clone()) + .use_full_join_and_coalesce(self.use_full_join_and_coalesce()) + .multiplied_measures_resolver(multiplied_measures_resolver) + .multi_stage_subquery_refs(self.multi_stage_subquery_refs().clone()) + .build(), + )) } fn node_name(&self) -> &'static str { @@ -122,22 +161,22 @@ impl PrettyPrint for FullKeyAggregate { let state = state.new_level(); let details_state = state.new_level(); result.println(&format!("schema:"), &state); - self.schema.pretty_print(result, &details_state); + self.schema().pretty_print(result, &details_state); result.println( &format!( "use_full_join_and_coalesce: {}", - self.use_full_join_and_coalesce + self.use_full_join_and_coalesce() ), &state, ); - if let Some(resolve_multiplied_measures) = &self.multiplied_measures_resolver { + if let Some(resolve_multiplied_measures) = self.multiplied_measures_resolver() { result.println("multiplied measures resolver:", &state); resolve_multiplied_measures.pretty_print(result, &details_state); } - if !self.multi_stage_subquery_refs.is_empty() { + if !self.multi_stage_subquery_refs().is_empty() { result.println("multi_stage_subquery_refs:", &state); - for subquery_ref in self.multi_stage_subquery_refs.iter() { + for subquery_ref in self.multi_stage_subquery_refs().iter() { subquery_ref.pretty_print(result, &details_state); } } diff --git a/rust/cubesqlplanner/cubesqlplanner/src/logical_plan/helper.rs b/rust/cubesqlplanner/cubesqlplanner/src/logical_plan/helper.rs new file mode 100644 index 0000000000000..b64a390e647f3 --- /dev/null +++ b/rust/cubesqlplanner/cubesqlplanner/src/logical_plan/helper.rs @@ -0,0 +1,17 @@ +use itertools::Itertools; + +use crate::planner::sql_evaluator::MemberSymbol; + +use super::*; +use std::rc::Rc; +pub fn all_symbols(schema: &Rc, filters: &LogicalFilter) -> Vec> { + let mut symbols = schema.all_members().cloned().collect_vec(); + + if let Some(dim_filter) = filters.all_filters() { + symbols.extend(dim_filter.all_member_evaluators().iter().cloned()); + } + if let Some(meas_filter) = filters.measures_filter() { + symbols.extend(meas_filter.all_member_evaluators().iter().cloned()); + } + symbols +} diff --git a/rust/cubesqlplanner/cubesqlplanner/src/logical_plan/join.rs b/rust/cubesqlplanner/cubesqlplanner/src/logical_plan/join.rs index 7aa79c18273e5..4b497be520cc2 100644 --- a/rust/cubesqlplanner/cubesqlplanner/src/logical_plan/join.rs +++ b/rust/cubesqlplanner/cubesqlplanner/src/logical_plan/join.rs @@ -3,26 +3,54 @@ use super::*; use crate::planner::sql_evaluator::SqlCall; use cubenativeutils::CubeError; use std::rc::Rc; +use typed_builder::TypedBuilder; -#[derive(Clone)] +#[derive(Clone, TypedBuilder)] pub struct LogicalJoinItem { - pub cube: Rc, - pub on_sql: Rc, + cube: Rc, + on_sql: Rc, +} + +impl LogicalJoinItem { + pub fn cube(&self) -> &Rc { + &self.cube + } + + pub fn on_sql(&self) -> &Rc { + &self.on_sql + } } impl PrettyPrint for LogicalJoinItem { fn pretty_print(&self, result: &mut PrettyPrintResult, state: &PrettyPrintState) { result.println(&format!("CubeJoinItem: "), state); let details_state = state.new_level(); - self.cube.pretty_print(result, &details_state); + self.cube().pretty_print(result, &details_state); } } -#[derive(Clone)] +#[derive(Clone, TypedBuilder)] pub struct LogicalJoin { - pub root: Rc, - pub joins: Vec, - pub dimension_subqueries: Vec>, + #[builder(default)] + root: Option>, + #[builder(default)] + joins: Vec, + #[builder(default)] + dimension_subqueries: Vec>, +} + +impl LogicalJoin { + pub fn root(&self) -> &Option> { + &self.root + } + + pub fn joins(&self) -> &Vec { + &self.joins + } + + pub fn dimension_subqueries(&self) -> &Vec> { + &self.dimension_subqueries + } } impl LogicalNode for LogicalJoin { @@ -41,26 +69,34 @@ impl LogicalNode for LogicalJoin { dimension_subqueries, } = LogicalJoinInputUnPacker::new(&self, &inputs)?; + let root = if let Some(r) = root { + Some(r.clone().into_logical_node()?) + } else { + None + }; + let joins = self - .joins + .joins() .iter() .zip(joins.iter()) .map(|(self_item, item)| -> Result<_, CubeError> { - Ok(LogicalJoinItem { - cube: item.clone().into_logical_node()?, - on_sql: self_item.on_sql.clone(), - }) + Ok(LogicalJoinItem::builder() + .cube(item.clone().into_logical_node()?) + .on_sql(self_item.on_sql().clone()) + .build()) }) .collect::, _>>()?; - let result = Self { - root: root.clone().into_logical_node()?, - joins, - dimension_subqueries: dimension_subqueries - .iter() - .map(|itm| itm.clone().into_logical_node()) - .collect::, _>>()?, - }; + let result = Self::builder() + .root(root) + .joins(joins) + .dimension_subqueries( + dimension_subqueries + .iter() + .map(|itm| itm.clone().into_logical_node()) + .collect::, _>>()?, + ) + .build(); Ok(Rc::new(result)) } @@ -82,10 +118,12 @@ pub struct LogicalJoinInputPacker; impl LogicalJoinInputPacker { pub fn pack(join: &LogicalJoin) -> Vec { let mut result = vec![]; - result.push(join.root.as_plan_node()); - result.extend(join.joins.iter().map(|item| item.cube.as_plan_node())); + if let Some(root) = join.root() { + result.push(root.as_plan_node()); + } + result.extend(join.joins().iter().map(|item| item.cube().as_plan_node())); result.extend( - join.dimension_subqueries + join.dimension_subqueries() .iter() .map(|item| item.as_plan_node()), ); @@ -94,7 +132,7 @@ impl LogicalJoinInputPacker { } pub struct LogicalJoinInputUnPacker<'a> { - root: &'a PlanNode, + root: Option<&'a PlanNode>, joins: &'a [PlanNode], dimension_subqueries: &'a [PlanNode], } @@ -103,9 +141,15 @@ impl<'a> LogicalJoinInputUnPacker<'a> { pub fn new(join: &LogicalJoin, inputs: &'a Vec) -> Result { check_inputs_len(&inputs, Self::inputs_len(join), join.node_name())?; - let root = &inputs[0]; - let joins_start = 1; - let joins_end = joins_start + join.joins.len(); + let mut joins_start = 0; + let root = if join.root.is_some() { + joins_start = 1; + Some(&inputs[0]) + } else { + None + }; + + let joins_end = joins_start + join.joins().len(); let joins = &inputs[joins_start..joins_end]; let dimension_subqueries = &inputs[joins_end..]; @@ -117,28 +161,33 @@ impl<'a> LogicalJoinInputUnPacker<'a> { } fn inputs_len(join: &LogicalJoin) -> usize { - 1 + join.joins.len() + join.dimension_subqueries.len() + 1 + join.joins().len() + join.dimension_subqueries().len() } } impl PrettyPrint for LogicalJoin { fn pretty_print(&self, result: &mut PrettyPrintResult, state: &PrettyPrintState) { - result.println(&format!("Join: "), state); - let state = state.new_level(); - let details_state = state.new_level(); - result.println(&format!("root: "), &state); - self.root.pretty_print(result, &details_state); - result.println(&format!("joins: "), &state); - let state = state.new_level(); - for join in self.joins.iter() { - join.pretty_print(result, &state); - } - if !self.dimension_subqueries.is_empty() { - result.println("dimension_subqueries:", &state); + if let Some(root) = self.root() { + result.println(&format!("Join: "), state); + + let state = state.new_level(); let details_state = state.new_level(); - for subquery in self.dimension_subqueries.iter() { - subquery.pretty_print(result, &details_state); + result.println(&format!("root: "), &state); + root.pretty_print(result, &details_state); + result.println(&format!("joins: "), &state); + let state = state.new_level(); + for join in self.joins().iter() { + join.pretty_print(result, &state); + } + if !self.dimension_subqueries().is_empty() { + result.println("dimension_subqueries:", &state); + let details_state = state.new_level(); + for subquery in self.dimension_subqueries().iter() { + subquery.pretty_print(result, &details_state); + } } + } else { + result.println(&format!("Empty source"), state); } } } diff --git a/rust/cubesqlplanner/cubesqlplanner/src/logical_plan/keys_subquery.rs b/rust/cubesqlplanner/cubesqlplanner/src/logical_plan/keys_subquery.rs index 506311593d175..deba366dc8a57 100644 --- a/rust/cubesqlplanner/cubesqlplanner/src/logical_plan/keys_subquery.rs +++ b/rust/cubesqlplanner/cubesqlplanner/src/logical_plan/keys_subquery.rs @@ -2,14 +2,33 @@ use super::*; use crate::planner::sql_evaluator::MemberSymbol; use cubenativeutils::CubeError; use std::rc::Rc; +use typed_builder::TypedBuilder; -#[derive(Clone)] +#[derive(Clone, TypedBuilder)] pub struct KeysSubQuery { - pub pk_cube: Rc, - pub schema: Rc, - pub primary_keys_dimensions: Vec>, - pub filter: Rc, - pub source: Rc, + pk_cube: Rc, + schema: Rc, + primary_keys_dimensions: Vec>, + filter: Rc, + source: Rc, +} + +impl KeysSubQuery { + pub fn pk_cube(&self) -> &Rc { + &self.pk_cube + } + pub fn schema(&self) -> &Rc { + &self.schema + } + pub fn primary_keys_dimensions(&self) -> &Vec> { + &self.primary_keys_dimensions + } + pub fn filter(&self) -> &Rc { + &self.filter + } + pub fn source(&self) -> &Rc { + &self.source + } } impl LogicalNode for KeysSubQuery { @@ -53,7 +72,7 @@ impl PrettyPrint for KeysSubQuery { result.println("KeysSubQuery: ", state); let state = state.new_level(); let details_state = state.new_level(); - result.println(&format!("pk_cube: {}", self.pk_cube.cube.name()), &state); + result.println(&format!("pk_cube: {}", self.pk_cube.cube().name()), &state); result.println("schema:", &state); self.schema.pretty_print(result, &details_state); diff --git a/rust/cubesqlplanner/cubesqlplanner/src/logical_plan/logical_node.rs b/rust/cubesqlplanner/cubesqlplanner/src/logical_plan/logical_node.rs index e0224694c419f..ebf38a64222d5 100644 --- a/rust/cubesqlplanner/cubesqlplanner/src/logical_plan/logical_node.rs +++ b/rust/cubesqlplanner/cubesqlplanner/src/logical_plan/logical_node.rs @@ -29,6 +29,7 @@ pub enum PlanNode { MultiStageGetDateRange(Rc), MultiStageLeafMeasure(Rc), MultiStageMeasureCalculation(Rc), + MultiStageDimensionCalculation(Rc), MultiStageTimeSeries(Rc), MultiStageRollingWindow(Rc), LogicalMultiStageMember(Rc), @@ -51,6 +52,7 @@ macro_rules! match_plan_node { PlanNode::MultiStageGetDateRange($node) => $block, PlanNode::MultiStageLeafMeasure($node) => $block, PlanNode::MultiStageMeasureCalculation($node) => $block, + PlanNode::MultiStageDimensionCalculation($node) => $block, PlanNode::MultiStageTimeSeries($node) => $block, PlanNode::MultiStageRollingWindow($node) => $block, PlanNode::LogicalMultiStageMember($node) => $block, diff --git a/rust/cubesqlplanner/cubesqlplanner/src/logical_plan/logical_source.rs b/rust/cubesqlplanner/cubesqlplanner/src/logical_plan/logical_source.rs new file mode 100644 index 0000000000000..09fa35796e1ed --- /dev/null +++ b/rust/cubesqlplanner/cubesqlplanner/src/logical_plan/logical_source.rs @@ -0,0 +1,64 @@ +use super::*; +use cubenativeutils::CubeError; + +pub trait LogicalSource: Sized + PrettyPrint { + fn as_plan_node(&self) -> PlanNode; + fn with_plan_node(&self, plan_node: PlanNode) -> Result; +} + +/// Generates an enum and trait implementations for LogicalSource types. +/// +/// This macro creates: +/// - An enum with variants wrapping `Rc` for each specified type +/// - LogicalSource trait implementation that delegates to inner types +/// - PrettyPrint trait implementation for debugging SQL plans +/// - From> implementations for convenient construction +/// +/// The enum variant name always matches the inner type name, and all variants +/// are wrapped in `Rc` for efficient cloning in the query planner. +macro_rules! logical_source_enum { + ($enum_name:ident, [$($variant:ident),+ $(,)?]) => { + #[derive(Clone)] + pub enum $enum_name { + $( + $variant(Rc<$variant>), + )+ + } + + impl LogicalSource for $enum_name { + fn as_plan_node(&self) -> PlanNode { + match self { + $( + Self::$variant(item) => item.as_plan_node(), + )+ + } + } + + fn with_plan_node(&self, plan_node: PlanNode) -> Result { + Ok(match self { + $( + Self::$variant(_) => Self::$variant(plan_node.into_logical_node()?), + )+ + }) + } + } + + impl PrettyPrint for $enum_name { + fn pretty_print(&self, result: &mut PrettyPrintResult, state: &PrettyPrintState) { + match self { + $( + Self::$variant(item) => item.pretty_print(result, state), + )+ + } + } + } + + $( + impl From> for $enum_name { + fn from(value: Rc<$variant>) -> Self { + Self::$variant(value) + } + } + )+ + }; +} diff --git a/rust/cubesqlplanner/cubesqlplanner/src/logical_plan/mod.rs b/rust/cubesqlplanner/cubesqlplanner/src/logical_plan/mod.rs index 2244c5d6b52b7..9649af4656ba7 100644 --- a/rust/cubesqlplanner/cubesqlplanner/src/logical_plan/mod.rs +++ b/rust/cubesqlplanner/cubesqlplanner/src/logical_plan/mod.rs @@ -1,8 +1,11 @@ +#[macro_use] +mod logical_source; mod aggregate_multiplied_subquery; mod cube; mod dimension_subquery; mod filter; mod full_key_aggregate; +mod helper; mod join; mod keys_subquery; mod logical_node; @@ -13,6 +16,7 @@ pub mod optimizers; mod pre_aggregation; pub mod pretty_print; mod query; +mod query_source; mod resolve_multiplied_measures; mod schema; pub mod visitor; @@ -22,15 +26,18 @@ pub use cube::*; pub use dimension_subquery::*; pub use filter::*; pub use full_key_aggregate::*; +pub use helper::*; pub use join::*; pub use keys_subquery::*; pub use logical_node::*; pub use logical_query_modifers::*; +pub use logical_source::*; pub use measure_subquery::*; pub use multistage::*; pub use optimizers::*; pub use pre_aggregation::*; pub use pretty_print::*; pub use query::*; +pub use query_source::*; pub use resolve_multiplied_measures::*; pub use schema::*; diff --git a/rust/cubesqlplanner/cubesqlplanner/src/logical_plan/multistage/calculation.rs b/rust/cubesqlplanner/cubesqlplanner/src/logical_plan/multistage/calculation.rs index 4afd6949deeaa..665ded2e1a02d 100644 --- a/rust/cubesqlplanner/cubesqlplanner/src/logical_plan/multistage/calculation.rs +++ b/rust/cubesqlplanner/cubesqlplanner/src/logical_plan/multistage/calculation.rs @@ -4,6 +4,7 @@ use crate::planner::sql_evaluator::MemberSymbol; use cubenativeutils::CubeError; use itertools::Itertools; use std::rc::Rc; +use typed_builder::TypedBuilder; #[derive(PartialEq, Clone)] pub enum MultiStageCalculationType { @@ -39,50 +40,86 @@ impl ToString for MultiStageCalculationWindowFunction { } } +#[derive(TypedBuilder)] pub struct MultiStageMeasureCalculation { - pub schema: Rc, - pub is_ungrouped: bool, - pub calculation_type: MultiStageCalculationType, - pub partition_by: Vec>, - pub window_function_to_use: MultiStageCalculationWindowFunction, - pub order_by: Vec, - pub source: Rc, + schema: Rc, + is_ungrouped: bool, + calculation_type: MultiStageCalculationType, + #[builder(default)] + partition_by: Vec>, + window_function_to_use: MultiStageCalculationWindowFunction, + #[builder(default)] + order_by: Vec, + source: Rc, +} + +impl MultiStageMeasureCalculation { + pub fn schema(&self) -> &Rc { + &self.schema + } + + pub fn is_ungrouped(&self) -> bool { + self.is_ungrouped + } + + pub fn calculation_type(&self) -> &MultiStageCalculationType { + &self.calculation_type + } + + pub fn partition_by(&self) -> &Vec> { + &self.partition_by + } + + pub fn window_function_to_use(&self) -> &MultiStageCalculationWindowFunction { + &self.window_function_to_use + } + + pub fn order_by(&self) -> &Vec { + &self.order_by + } + + pub fn source(&self) -> &Rc { + &self.source + } } impl PrettyPrint for MultiStageMeasureCalculation { fn pretty_print(&self, result: &mut PrettyPrintResult, state: &PrettyPrintState) { result.println( - &format!("Measure Calculation: {}", self.calculation_type.to_string()), + &format!( + "Measure Calculation: {}", + self.calculation_type().to_string() + ), state, ); let state = state.new_level(); let details_state = state.new_level(); result.println("schema:", &state); - self.schema.pretty_print(result, &details_state); - if !self.partition_by.is_empty() { + self.schema().pretty_print(result, &details_state); + if !self.partition_by().is_empty() { result.println( &format!( "partition_by: {}", - self.partition_by.iter().map(|m| m.full_name()).join(", ") + self.partition_by().iter().map(|m| m.full_name()).join(", ") ), &state, ); } - if self.window_function_to_use != MultiStageCalculationWindowFunction::None { + if self.window_function_to_use() != &MultiStageCalculationWindowFunction::None { result.println( &format!( "window_function_to_use: {}", - self.window_function_to_use.to_string() + self.window_function_to_use().to_string() ), &state, ); } - if self.is_ungrouped { + if self.is_ungrouped() { result.println("is_ungrouped: true", &state); } - if !self.order_by.is_empty() { + if !self.order_by().is_empty() { result.println("order_by:", &state); - for order_by in self.order_by.iter() { + for order_by in self.order_by().iter() { result.println( &format!( "{} {}", @@ -94,7 +131,7 @@ impl PrettyPrint for MultiStageMeasureCalculation { } } result.println("source:", &state); - self.source.pretty_print(result, &details_state); + self.source().pretty_print(result, &details_state); } } @@ -104,22 +141,24 @@ impl LogicalNode for MultiStageMeasureCalculation { } fn inputs(&self) -> Vec { - vec![self.source.as_plan_node()] + vec![self.source().as_plan_node()] } fn with_inputs(self: Rc, inputs: Vec) -> Result, CubeError> { check_inputs_len(&inputs, 1, self.node_name())?; let source = &inputs[0]; - Ok(Rc::new(Self { - schema: self.schema.clone(), - is_ungrouped: self.is_ungrouped, - calculation_type: self.calculation_type.clone(), - partition_by: self.partition_by.clone(), - window_function_to_use: self.window_function_to_use.clone(), - order_by: self.order_by.clone(), - source: source.clone().into_logical_node()?, - })) + Ok(Rc::new( + Self::builder() + .schema(self.schema().clone()) + .is_ungrouped(self.is_ungrouped()) + .calculation_type(self.calculation_type().clone()) + .partition_by(self.partition_by().clone()) + .window_function_to_use(self.window_function_to_use().clone()) + .order_by(self.order_by().clone()) + .source(source.clone().into_logical_node()?) + .build(), + )) } fn node_name(&self) -> &'static str { diff --git a/rust/cubesqlplanner/cubesqlplanner/src/logical_plan/multistage/dimension.rs b/rust/cubesqlplanner/cubesqlplanner/src/logical_plan/multistage/dimension.rs new file mode 100644 index 0000000000000..f37f2ce336541 --- /dev/null +++ b/rust/cubesqlplanner/cubesqlplanner/src/logical_plan/multistage/dimension.rs @@ -0,0 +1,116 @@ +use crate::logical_plan::*; +use crate::planner::query_properties::OrderByItem; +use crate::planner::sql_evaluator::collectors::has_multi_stage_members; +use crate::planner::sql_evaluator::MemberSymbol; +use cubenativeutils::CubeError; +use std::rc::Rc; +use typed_builder::TypedBuilder; + +#[derive(TypedBuilder)] +pub struct MultiStageDimensionCalculation { + schema: Rc, + multi_stage_dimension: Rc, + #[builder(default)] + order_by: Vec, + source: Rc, +} + +impl MultiStageDimensionCalculation { + pub fn schema(&self) -> &Rc { + &self.schema + } + + pub fn multi_stage_dimension(&self) -> &Rc { + &self.multi_stage_dimension + } + + pub fn order_by(&self) -> &Vec { + &self.order_by + } + + pub fn source(&self) -> &Rc { + &self.source + } + + pub fn resolved_dimensions(&self) -> Result, CubeError> { + let mut result = vec![]; + for dim in self.schema.all_dimensions() { + if has_multi_stage_members(dim, true)? { + result.push(dim.clone().resolve_reference_chain().full_name()); + } + } + result.sort(); + Ok(result) + } + + pub fn join_dimensions(&self) -> Result>, CubeError> { + let mut result = vec![]; + for dim in self.schema.all_dimensions() { + if !has_multi_stage_members(dim, true)? { + result.push(dim.clone()); + } + } + Ok(result) + } +} + +impl PrettyPrint for MultiStageDimensionCalculation { + fn pretty_print(&self, result: &mut PrettyPrintResult, state: &PrettyPrintState) { + result.println(&format!("Dimension Calculation",), state); + let state = state.new_level(); + let details_state = state.new_level(); + result.println("schema:", &state); + self.schema().pretty_print(result, &details_state); + if !self.order_by().is_empty() { + result.println("order_by:", &state); + for order_by in self.order_by().iter() { + result.println( + &format!( + "{} {}", + order_by.name(), + if order_by.desc() { "desc" } else { "asc" } + ), + &details_state, + ); + } + } + result.println("source:", &state); + self.source().pretty_print(result, &details_state); + } +} + +impl LogicalNode for MultiStageDimensionCalculation { + fn as_plan_node(self: &Rc) -> PlanNode { + PlanNode::MultiStageDimensionCalculation(self.clone()) + } + + fn inputs(&self) -> Vec { + vec![self.source().as_plan_node()] + } + + fn with_inputs(self: Rc, inputs: Vec) -> Result, CubeError> { + check_inputs_len(&inputs, 1, self.node_name())?; + let source = &inputs[0]; + + Ok(Rc::new( + Self::builder() + .schema(self.schema().clone()) + .order_by(self.order_by().clone()) + .multi_stage_dimension(self.multi_stage_dimension.clone()) + .source(source.clone().into_logical_node()?) + .build(), + )) + } + + fn node_name(&self) -> &'static str { + "MultiStageDimensionCalculation" + } + + fn try_from_plan_node(plan_node: PlanNode) -> Result, CubeError> { + if let PlanNode::MultiStageDimensionCalculation(item) = plan_node { + Ok(item) + } else { + Err(cast_error(&plan_node, "MultiStageMeasureCalculation")) + } + } +} diff --git a/rust/cubesqlplanner/cubesqlplanner/src/logical_plan/multistage/member.rs b/rust/cubesqlplanner/cubesqlplanner/src/logical_plan/multistage/member.rs index 6e7d9db81d907..299b6ef14f910 100644 --- a/rust/cubesqlplanner/cubesqlplanner/src/logical_plan/multistage/member.rs +++ b/rust/cubesqlplanner/cubesqlplanner/src/logical_plan/multistage/member.rs @@ -5,6 +5,7 @@ use std::rc::Rc; pub enum MultiStageMemberLogicalType { LeafMeasure(Rc), MeasureCalculation(Rc), + DimensionCalculation(Rc), GetDateRange(Rc), TimeSeries(Rc), RollingWindow(Rc), @@ -15,6 +16,7 @@ impl MultiStageMemberLogicalType { match self { Self::LeafMeasure(item) => item.as_plan_node(), Self::MeasureCalculation(item) => item.as_plan_node(), + Self::DimensionCalculation(item) => item.as_plan_node(), Self::GetDateRange(item) => item.as_plan_node(), Self::TimeSeries(item) => item.as_plan_node(), Self::RollingWindow(item) => item.as_plan_node(), @@ -25,6 +27,9 @@ impl MultiStageMemberLogicalType { Ok(match self { Self::LeafMeasure(_) => Self::LeafMeasure(plan_node.into_logical_node()?), Self::MeasureCalculation(_) => Self::MeasureCalculation(plan_node.into_logical_node()?), + Self::DimensionCalculation(_) => { + Self::DimensionCalculation(plan_node.into_logical_node()?) + } Self::GetDateRange(_) => Self::GetDateRange(plan_node.into_logical_node()?), Self::TimeSeries(_) => Self::TimeSeries(plan_node.into_logical_node()?), Self::RollingWindow(_) => Self::RollingWindow(plan_node.into_logical_node()?), @@ -37,6 +42,7 @@ impl PrettyPrint for MultiStageMemberLogicalType { match self { Self::LeafMeasure(measure) => measure.pretty_print(result, state), Self::MeasureCalculation(calculation) => calculation.pretty_print(result, state), + Self::DimensionCalculation(calculation) => calculation.pretty_print(result, state), Self::GetDateRange(get_date_range) => get_date_range.pretty_print(result, state), Self::TimeSeries(time_series) => time_series.pretty_print(result, state), Self::RollingWindow(rolling_window) => rolling_window.pretty_print(result, state), diff --git a/rust/cubesqlplanner/cubesqlplanner/src/logical_plan/multistage/mod.rs b/rust/cubesqlplanner/cubesqlplanner/src/logical_plan/multistage/mod.rs index f3d45e4177cc4..3a82b775bc971 100644 --- a/rust/cubesqlplanner/cubesqlplanner/src/logical_plan/multistage/mod.rs +++ b/rust/cubesqlplanner/cubesqlplanner/src/logical_plan/multistage/mod.rs @@ -1,5 +1,6 @@ mod calculation; mod common; +mod dimension; mod get_date_range; mod leaf_measure; mod member; @@ -7,6 +8,7 @@ mod rolling_window; mod time_series; pub use calculation::*; +pub use dimension::*; pub use get_date_range::*; pub use leaf_measure::*; pub use member::*; diff --git a/rust/cubesqlplanner/cubesqlplanner/src/logical_plan/multistage/time_series.rs b/rust/cubesqlplanner/cubesqlplanner/src/logical_plan/multistage/time_series.rs index f44ceeebd849c..7705533c9e419 100644 --- a/rust/cubesqlplanner/cubesqlplanner/src/logical_plan/multistage/time_series.rs +++ b/rust/cubesqlplanner/cubesqlplanner/src/logical_plan/multistage/time_series.rs @@ -2,10 +2,29 @@ use crate::logical_plan::*; use crate::planner::sql_evaluator::MemberSymbol; use cubenativeutils::CubeError; use std::rc::Rc; +use typed_builder::TypedBuilder; + +#[derive(TypedBuilder)] pub struct MultiStageTimeSeries { - pub time_dimension: Rc, - pub date_range: Option>, - pub get_date_range_multistage_ref: Option, + time_dimension: Rc, + #[builder(default)] + date_range: Option>, + #[builder(default)] + get_date_range_multistage_ref: Option, +} + +impl MultiStageTimeSeries { + pub fn time_dimension(&self) -> &Rc { + &self.time_dimension + } + + pub fn date_range(&self) -> &Option> { + &self.date_range + } + + pub fn get_date_range_multistage_ref(&self) -> &Option { + &self.get_date_range_multistage_ref + } } impl PrettyPrint for MultiStageTimeSeries { @@ -13,16 +32,16 @@ impl PrettyPrint for MultiStageTimeSeries { result.println("Time Series", state); let state = state.new_level(); result.println( - &format!("time_dimension: {}", self.time_dimension.full_name()), + &format!("time_dimension: {}", self.time_dimension().full_name()), &state, ); - if let Some(date_range) = &self.date_range { + if let Some(date_range) = self.date_range() { result.println( &format!("date_range: [{}, {}]", date_range[0], date_range[1]), &state, ); } - if let Some(get_date_range_multistage_ref) = &self.get_date_range_multistage_ref { + if let Some(get_date_range_multistage_ref) = self.get_date_range_multistage_ref() { result.println( &format!( "get_date_range_multistage_ref: {}", diff --git a/rust/cubesqlplanner/cubesqlplanner/src/logical_plan/optimizers/common/cube_names_collector.rs b/rust/cubesqlplanner/cubesqlplanner/src/logical_plan/optimizers/common/cube_names_collector.rs index a46fd257ecf57..3be34c87a8d70 100644 --- a/rust/cubesqlplanner/cubesqlplanner/src/logical_plan/optimizers/common/cube_names_collector.rs +++ b/rust/cubesqlplanner/cubesqlplanner/src/logical_plan/optimizers/common/cube_names_collector.rs @@ -12,7 +12,7 @@ struct CubeNamesCollector { impl LogicalNodeVisitor for CubeNamesCollector { fn process_node(&mut self, node: &PlanNode) -> Result<(), CubeError> { if let PlanNode::Cube(cube) = node { - self.cube_names.insert(cube.name.clone()); + self.cube_names.insert(cube.name().clone()); } Ok(()) } diff --git a/rust/cubesqlplanner/cubesqlplanner/src/logical_plan/optimizers/pre_aggregation/dimension_matcher.rs b/rust/cubesqlplanner/cubesqlplanner/src/logical_plan/optimizers/pre_aggregation/dimension_matcher.rs index 2be3c168f379e..ee533be3e93c7 100644 --- a/rust/cubesqlplanner/cubesqlplanner/src/logical_plan/optimizers/pre_aggregation/dimension_matcher.rs +++ b/rust/cubesqlplanner/cubesqlplanner/src/logical_plan/optimizers/pre_aggregation/dimension_matcher.rs @@ -270,6 +270,7 @@ impl<'a> DimensionMatcher<'a> { filter.member_evaluator().clone() }; let add_to_matched_dimension = add_to_matched_dimension && filter.is_single_value_equal(); - self.try_match_symbol(&symbol, add_to_matched_dimension) + let res = self.try_match_symbol(&symbol, add_to_matched_dimension)?; + Ok(res) } } diff --git a/rust/cubesqlplanner/cubesqlplanner/src/logical_plan/optimizers/pre_aggregation/optimizer.rs b/rust/cubesqlplanner/cubesqlplanner/src/logical_plan/optimizers/pre_aggregation/optimizer.rs index d0d877d48d856..e54410a735ebf 100644 --- a/rust/cubesqlplanner/cubesqlplanner/src/logical_plan/optimizers/pre_aggregation/optimizer.rs +++ b/rust/cubesqlplanner/cubesqlplanner/src/logical_plan/optimizers/pre_aggregation/optimizer.rs @@ -49,7 +49,7 @@ impl PreAggregationOptimizer { query: Rc, pre_aggregation: &Rc, ) -> Result>, CubeError> { - if query.multistage_members.is_empty() { + if query.multistage_members().is_empty() { self.try_rewrite_simple_query(&query, pre_aggregation) } else if !self.allow_multi_stage { Ok(None) @@ -63,10 +63,9 @@ impl PreAggregationOptimizer { query: &Rc, pre_aggregation: &Rc, ) -> Result>, CubeError> { - if self.is_schema_and_filters_match(&query.schema, &query.filter, pre_aggregation)? { + if self.is_schema_and_filters_match(&query.schema(), &query.filter(), pre_aggregation)? { let mut new_query = query.as_ref().clone(); - new_query.source = - QuerySource::PreAggregation(self.make_pre_aggregation_source(pre_aggregation)?); + new_query.set_source(self.make_pre_aggregation_source(pre_aggregation)?.into()); Ok(Some(Rc::new(new_query))) } else { Ok(None) @@ -82,7 +81,7 @@ impl PreAggregationOptimizer { let mut has_unrewritten_leaf = false; let mut rewritten_multistages = Vec::new(); - for multi_stage in &query.multistage_members { + for multi_stage in query.multistage_members() { let rewritten = rewriter.rewrite_top_down_with(multi_stage.clone(), |plan_node| { let res = match plan_node { PlanNode::MultiStageLeafMeasure(multi_stage_leaf_measure) => { @@ -119,9 +118,9 @@ impl PreAggregationOptimizer { return Ok(None); } - let source = if let QuerySource::FullKeyAggregate(full_key_aggregate) = &query.source { + let source = if let QuerySource::FullKeyAggregate(full_key_aggregate) = query.source() { let fk_source = if let Some(resolver_multiplied_measures) = - &full_key_aggregate.multiplied_measures_resolver + full_key_aggregate.multiplied_measures_resolver() { if let ResolvedMultipliedMeasures::ResolveMultipliedMeasures( resolver_multiplied_measures, @@ -135,18 +134,17 @@ impl PreAggregationOptimizer { let pre_aggregation_source = self.make_pre_aggregation_source(pre_aggregation)?; - let pre_aggregation_query = Query { - schema: resolver_multiplied_measures.schema.clone(), - filter: resolver_multiplied_measures.filter.clone(), - modifers: Rc::new(LogicalQueryModifiers { + let pre_aggregation_query = Query::builder() + .schema(resolver_multiplied_measures.schema.clone()) + .filter(resolver_multiplied_measures.filter.clone()) + .modifers(Rc::new(LogicalQueryModifiers { offset: None, limit: None, ungrouped: false, order_by: vec![], - }), - source: QuerySource::PreAggregation(pre_aggregation_source), - multistage_members: vec![], - }; + })) + .source(pre_aggregation_source.into()) + .build(); Some(ResolvedMultipliedMeasures::PreAggregation(Rc::new( pre_aggregation_query, ))) @@ -159,20 +157,24 @@ impl PreAggregationOptimizer { } else { None }; - let mut result = full_key_aggregate.as_ref().clone(); - result.multiplied_measures_resolver = fk_source; - QuerySource::FullKeyAggregate(Rc::new(result)) + let result = FullKeyAggregate::builder() + .schema(full_key_aggregate.schema().clone()) + .use_full_join_and_coalesce(full_key_aggregate.use_full_join_and_coalesce()) + .multiplied_measures_resolver(fk_source) + .multi_stage_subquery_refs(full_key_aggregate.multi_stage_subquery_refs().clone()) + .build(); + Rc::new(result).into() } else { - query.source.clone() + query.source().clone() }; - let result = Query { - multistage_members: rewritten_multistages, - schema: query.schema.clone(), - filter: query.filter.clone(), - modifers: query.modifers.clone(), - source, - }; + let result = Query::builder() + .multistage_members(rewritten_multistages) + .schema(query.schema().clone()) + .filter(query.filter().clone()) + .modifers(query.modifers().clone()) + .source(source) + .build(); Ok(Some(Rc::new(result))) } @@ -390,20 +392,20 @@ impl PreAggregationOptimizer { measures: pre_aggregation.measures.to_vec(), multiplied_measures: HashSet::new(), }; - let pre_aggregation = PreAggregation { - name: pre_aggregation.name.clone(), - time_dimensions: pre_aggregation.time_dimensions.clone(), - dimensions: pre_aggregation.dimensions.clone(), - measures: pre_aggregation.measures.clone(), - schema: Rc::new(schema), - external: pre_aggregation.external.unwrap_or_default(), - granularity: pre_aggregation.granularity.clone(), - source: pre_aggregation.source.clone(), - cube_name: pre_aggregation.cube_name.clone(), - }; + let pre_aggregation = PreAggregation::builder() + .name(pre_aggregation.name.clone()) + .time_dimensions(pre_aggregation.time_dimensions.clone()) + .dimensions(pre_aggregation.dimensions.clone()) + .measures(pre_aggregation.measures.clone()) + .schema(Rc::new(schema)) + .external(pre_aggregation.external.unwrap_or_default()) + .granularity(pre_aggregation.granularity.clone()) + .source(pre_aggregation.source.clone()) + .cube_name(pre_aggregation.cube_name.clone()) + .build(); let result = Rc::new(pre_aggregation); self.used_pre_aggregations.insert( - (result.cube_name.clone(), result.name.clone()), + (result.cube_name().clone(), result.name().clone()), result.clone(), ); Ok(result) diff --git a/rust/cubesqlplanner/cubesqlplanner/src/logical_plan/optimizers/pre_aggregation/original_sql_optimizer.rs b/rust/cubesqlplanner/cubesqlplanner/src/logical_plan/optimizers/pre_aggregation/original_sql_optimizer.rs deleted file mode 100644 index 28a565772b1ac..0000000000000 --- a/rust/cubesqlplanner/cubesqlplanner/src/logical_plan/optimizers/pre_aggregation/original_sql_optimizer.rs +++ /dev/null @@ -1,358 +0,0 @@ -use super::PreAggregationsCompiler; -use super::*; -use crate::logical_plan::*; -use crate::planner::query_tools::QueryTools; -use cubenativeutils::CubeError; -use std::collections::HashMap; -use std::rc::Rc; - -pub struct OriginalSqlOptimizer { - query_tools: Rc, - foud_pre_aggregations: HashMap>, -} - -impl OriginalSqlOptimizer { - pub fn new(query_tools: Rc) -> Self { - Self { - query_tools, - foud_pre_aggregations: HashMap::new(), - } - } - - pub fn try_optimize(&mut self, plan: &Rc) -> Result>, CubeError> { - let res = match plan.as_ref() { - Query::SimpleQuery(query) => self - .try_optimize_simple_query(query)? - .map(|optimized| Rc::new(Query::SimpleQuery(optimized))), - Query::FullKeyAggregateQuery(query) => self - .try_optimize_full_key_aggregate_query(query)? - .map(|optimized| Rc::new(Query::FullKeyAggregateQuery(optimized))), - }; - Ok(res) - } - - fn try_optimize_full_key_aggregate_query( - &mut self, - query: &FullKeyAggregateQuery, - ) -> Result, CubeError> { - let optimized_source = self.try_optimize_full_key_aggregate(&query.source)?; - if optimized_source.is_some() { - Ok(Some(FullKeyAggregateQuery { - multistage_members: query.multistage_members.clone(), - schema: query.schema.clone(), - filter: query.filter.clone(), - modifers: query.modifers.clone(), - source: optimized_source.unwrap_or_else(|| query.source.clone()), - })) - } else { - Ok(None) - } - } - - fn try_optimize_full_key_aggregate( - &mut self, - full_key_aggregate: &Rc, - ) -> Result>, CubeError> { - let res = if let Some(resolver) = &full_key_aggregate.multiplied_measures_resolver { - if let Some(optimized_resolver) = - self.try_optimize_resolved_multiplied_measures(resolver)? - { - Some(Rc::new(FullKeyAggregate { - multiplied_measures_resolver: Some(optimized_resolver), - multi_stage_subquery_refs: full_key_aggregate.multi_stage_subquery_refs.clone(), - join_dimensions: full_key_aggregate.join_dimensions.clone(), - use_full_join_and_coalesce: full_key_aggregate.use_full_join_and_coalesce, - })) - } else { - None - } - } else { - None - }; - Ok(res) - } - - fn try_optimize_resolved_multiplied_measures( - &mut self, - source: &ResolvedMultipliedMeasures, - ) -> Result, CubeError> { - let res = match source { - ResolvedMultipliedMeasures::ResolveMultipliedMeasures(resolve_multiplied_measures) => { - self.try_optimize_multiplied_measures_resolver(resolve_multiplied_measures)? - .map(|resolver| ResolvedMultipliedMeasures::ResolveMultipliedMeasures(resolver)) - } - ResolvedMultipliedMeasures::PreAggregation(_) => None, - }; - Ok(res) - } - - fn try_optimize_multiplied_measures_resolver( - &mut self, - resolver: &Rc, - ) -> Result>, CubeError> { - let optimized_regular_measure_subqueries = resolver - .regular_measure_subqueries - .iter() - .map(|subquery| self.try_optimize_simple_query(subquery)) - .collect::, _>>()?; - let optimized_multiplied_subqueries = resolver - .aggregate_multiplied_subqueries - .iter() - .map(|subquery| self.try_optimize_aggregate_multiplied_subquery(subquery)) - .collect::, _>>()?; - let res = if optimized_regular_measure_subqueries - .iter() - .any(|subquery| subquery.is_some()) - || optimized_multiplied_subqueries - .iter() - .any(|subquery| subquery.is_some()) - { - Some(Rc::new(ResolveMultipliedMeasures { - schema: resolver.schema.clone(), - filter: resolver.filter.clone(), - regular_measure_subqueries: optimized_regular_measure_subqueries - .into_iter() - .zip(resolver.regular_measure_subqueries.iter()) - .map(|(optimized, original)| { - optimized.map_or_else(|| original.clone(), |v| Rc::new(v)) - }) - .collect(), - aggregate_multiplied_subqueries: optimized_multiplied_subqueries - .into_iter() - .zip(resolver.aggregate_multiplied_subqueries.iter()) - .map(|(optimized, original)| optimized.unwrap_or_else(|| original.clone())) - .collect(), - })) - } else { - None - }; - Ok(res) - } - - fn try_optimize_simple_query( - &mut self, - query: &SimpleQuery, - ) -> Result, CubeError> { - let optimized_source = self.try_optimize_simple_query_source(&query.source)?; - let optimized_dimension_subqueries = - self.try_optimize_dimension_subqueries(&query.dimension_subqueries)?; - if optimized_source.is_some() || optimized_dimension_subqueries.is_some() { - Ok(Some(SimpleQuery { - source: optimized_source.unwrap_or_else(|| query.source.clone()), - dimension_subqueries: optimized_dimension_subqueries - .unwrap_or_else(|| query.dimension_subqueries.clone()), - schema: query.schema.clone(), - filter: query.filter.clone(), - modifers: query.modifers.clone(), - })) - } else { - Ok(None) - } - } - - fn try_optimize_simple_query_source( - &mut self, - source: &SimpleQuerySource, - ) -> Result, CubeError> { - match source { - SimpleQuerySource::LogicalJoin(join) => Ok(self - .try_optimize_logical_join(join)? - .map(|join| SimpleQuerySource::LogicalJoin(join))), - SimpleQuerySource::PreAggregation(_) => Ok(None), - } - } - - fn try_optimize_aggregate_multiplied_subquery( - &mut self, - subquery: &Rc, - ) -> Result>, CubeError> { - let optimized_keys_subquery = self.try_optimize_keys_subquery(&subquery.keys_subquery)?; - let optimized_pk_cube = self.try_optimize_cube(subquery.pk_cube.clone())?; - let optimized_source = match subquery.source.as_ref() { - AggregateMultipliedSubquerySouce::Cube => None, - AggregateMultipliedSubquerySouce::MeasureSubquery(measure_subquery) => self - .try_optimize_measure_subquery(&measure_subquery)? - .map(|measure_subquery| { - Rc::new(AggregateMultipliedSubquerySouce::MeasureSubquery( - measure_subquery, - )) - }), - }; - let optimized_dimension_subqueries = - self.try_optimize_dimension_subqueries(&subquery.dimension_subqueries)?; - if optimized_keys_subquery.is_some() - || optimized_source.is_some() - || optimized_dimension_subqueries.is_some() - || optimized_pk_cube.is_some() - { - Ok(Some(Rc::new(AggregateMultipliedSubquery { - keys_subquery: optimized_keys_subquery - .unwrap_or_else(|| subquery.keys_subquery.clone()), - source: optimized_source.unwrap_or_else(|| subquery.source.clone()), - pk_cube: optimized_pk_cube.unwrap_or_else(|| subquery.pk_cube.clone()), - schema: subquery.schema.clone(), - dimension_subqueries: optimized_dimension_subqueries - .unwrap_or_else(|| subquery.dimension_subqueries.clone()), - }))) - } else { - Ok(None) - } - } - - fn try_optimize_keys_subquery( - &mut self, - subquery: &Rc, - ) -> Result>, CubeError> { - let optimized_source = self.try_optimize_logical_join(&subquery.source)?; - let optimized_dimension_subqueries = - self.try_optimize_dimension_subqueries(&subquery.dimension_subqueries)?; - if optimized_source.is_some() || optimized_dimension_subqueries.is_some() { - Ok(Some(Rc::new(KeysSubQuery { - key_cube_name: subquery.key_cube_name.clone(), - time_dimensions: subquery.time_dimensions.clone(), - dimensions: subquery.dimensions.clone(), - dimension_subqueries: optimized_dimension_subqueries - .unwrap_or_else(|| subquery.dimension_subqueries.clone()), - primary_keys_dimensions: subquery.primary_keys_dimensions.clone(), - filter: subquery.filter.clone(), - source: optimized_source.unwrap_or_else(|| subquery.source.clone()), - }))) - } else { - Ok(None) - } - } - - fn try_optimize_measure_subquery( - &mut self, - subquery: &Rc, - ) -> Result>, CubeError> { - let optimized_source = self.try_optimize_logical_join(&subquery.source)?; - let optimized_dimension_subqueries = - self.try_optimize_dimension_subqueries(&subquery.dimension_subqueries)?; - if optimized_source.is_some() || optimized_dimension_subqueries.is_some() { - Ok(Some(Rc::new(MeasureSubquery { - primary_keys_dimensions: subquery.primary_keys_dimensions.clone(), - measures: subquery.measures.clone(), - dimension_subqueries: optimized_dimension_subqueries - .unwrap_or_else(|| subquery.dimension_subqueries.clone()), - source: optimized_source.unwrap_or_else(|| subquery.source.clone()), - }))) - } else { - Ok(None) - } - } - - fn try_optimize_dimension_subqueries( - &mut self, - dimension_subqueries: &Vec>, - ) -> Result>>, CubeError> { - let optimized = dimension_subqueries - .iter() - .map(|subquery| self.try_optimize_dimension_subquery(subquery)) - .collect::, _>>()?; - let res = if optimized.iter().any(|subquery| subquery.is_some()) { - Some( - optimized - .into_iter() - .zip(dimension_subqueries.iter()) - .map(|(optimized, original)| optimized.unwrap_or_else(|| original.clone())) - .collect(), - ) - } else { - None - }; - Ok(res) - } - - fn try_optimize_dimension_subquery( - &mut self, - subquery: &Rc, - ) -> Result>, CubeError> { - if let Some(optimized) = self.try_optimize(&subquery.query)? { - Ok(Some(Rc::new(DimensionSubQuery { - query: optimized, - primary_keys_dimensions: subquery.primary_keys_dimensions.clone(), - subquery_dimension: subquery.subquery_dimension.clone(), - measure_for_subquery_dimension: subquery.measure_for_subquery_dimension.clone(), - }))) - } else { - Ok(None) - } - } - - fn try_optimize_logical_join( - &mut self, - join: &Rc, - ) -> Result>, CubeError> { - let optimized_root = self.try_optimize_cube(join.root.clone())?; - let optimized_items = join - .joins - .iter() - .map(|join_item| self.try_optimize_join_item(join_item)) - .collect::, _>>()?; - - let result = - if optimized_root.is_some() || optimized_items.iter().any(|item| item.is_some()) { - Some(Rc::new(LogicalJoin { - root: optimized_root.unwrap_or_else(|| join.root.clone()), - joins: optimized_items - .into_iter() - .zip(join.joins.iter()) - .map(|(optimized, original)| optimized.unwrap_or_else(|| original.clone())) - .collect(), - })) - } else { - None - }; - Ok(result) - } - - fn try_optimize_cube(&mut self, cube: Rc) -> Result>, CubeError> { - let res = if let Some(found_pre_aggregation) = - self.find_origin_sql_pre_aggregation(&cube.name)? - { - Some( - cube.with_original_sql_pre_aggregation(OriginalSqlPreAggregation { - name: found_pre_aggregation.name.clone(), - }), - ) - } else { - None - }; - Ok(res) - } - - fn try_optimize_join_item( - &mut self, - join_item: &LogicalJoinItem, - ) -> Result, CubeError> { - match join_item { - LogicalJoinItem::CubeJoinItem(cube_join_item) => { - if let Some(optimized_cube) = self.try_optimize_cube(cube_join_item.cube.clone())? { - Ok(Some(LogicalJoinItem::CubeJoinItem(CubeJoinItem { - cube: optimized_cube, - on_sql: cube_join_item.on_sql.clone(), - }))) - } else { - Ok(None) - } - } - } - } - - fn find_origin_sql_pre_aggregation( - &mut self, - cube_name: &String, - ) -> Result>, CubeError> { - let res = if let Some(found_pre_aggregation) = self.foud_pre_aggregations.get(cube_name) { - Some(found_pre_aggregation.clone()) - } else { - let mut compiler = PreAggregationsCompiler::try_new( - self.query_tools.clone(), - &vec![cube_name.clone()], - )?; - compiler.compile_origin_sql_pre_aggregation(&cube_name)? - }; - Ok(res) - } -} diff --git a/rust/cubesqlplanner/cubesqlplanner/src/logical_plan/pre_aggregation.rs b/rust/cubesqlplanner/cubesqlplanner/src/logical_plan/pre_aggregation.rs index 955f73afa9ba8..43a6d4d607a72 100644 --- a/rust/cubesqlplanner/cubesqlplanner/src/logical_plan/pre_aggregation.rs +++ b/rust/cubesqlplanner/cubesqlplanner/src/logical_plan/pre_aggregation.rs @@ -3,17 +3,61 @@ use crate::{plan::QualifiedColumnName, planner::sql_evaluator::MemberSymbol}; use cubenativeutils::CubeError; use itertools::Itertools; use std::{collections::HashMap, rc::Rc}; +use typed_builder::TypedBuilder; +#[derive(TypedBuilder)] pub struct PreAggregation { - pub name: String, - pub schema: Rc, - pub measures: Vec>, - pub dimensions: Vec>, - pub time_dimensions: Vec<(Rc, Option)>, - pub external: bool, - pub granularity: Option, - pub source: Rc, - pub cube_name: String, + name: String, + schema: Rc, + #[builder(default)] + measures: Vec>, + #[builder(default)] + dimensions: Vec>, + #[builder(default)] + time_dimensions: Vec<(Rc, Option)>, + external: bool, + #[builder(default)] + granularity: Option, + source: Rc, + cube_name: String, +} + +impl PreAggregation { + pub fn name(&self) -> &String { + &self.name + } + + pub fn schema(&self) -> &Rc { + &self.schema + } + + pub fn measures(&self) -> &Vec> { + &self.measures + } + + pub fn dimensions(&self) -> &Vec> { + &self.dimensions + } + + pub fn time_dimensions(&self) -> &Vec<(Rc, Option)> { + &self.time_dimensions + } + + pub fn external(&self) -> bool { + self.external + } + + pub fn granularity(&self) -> &Option { + &self.granularity + } + + pub fn source(&self) -> &Rc { + &self.source + } + + pub fn cube_name(&self) -> &String { + &self.cube_name + } } impl LogicalNode for PreAggregation { @@ -46,14 +90,14 @@ impl PreAggregation { pub fn all_dimensions_refererences(&self) -> HashMap { let mut res = HashMap::new(); - for dim in self.dimensions.iter() { + for dim in self.dimensions().iter() { let alias = dim.alias(); res.insert( dim.full_name(), QualifiedColumnName::new(None, alias.clone()), ); } - for (dim, granularity) in self.time_dimensions.iter() { + for (dim, granularity) in self.time_dimensions().iter() { let base_symbol = if let Ok(td) = dim.as_time_dimension() { td.base_symbol().clone() } else { @@ -71,7 +115,7 @@ impl PreAggregation { ); } - if let PreAggregationSource::Join(join) = self.source.as_ref() { + if let PreAggregationSource::Join(join) = self.source().as_ref() { for item in join.items.iter() { for member in item.from_members.iter().chain(item.to_members.iter()) { let alias = member.alias(); @@ -86,7 +130,7 @@ impl PreAggregation { res } pub fn all_measures_refererences(&self) -> HashMap { - self.measures + self.measures() .iter() .map(|measure| { let alias = measure.alias(); @@ -103,10 +147,10 @@ impl PrettyPrint for PreAggregation { fn pretty_print(&self, result: &mut PrettyPrintResult, state: &PrettyPrintState) { result.println("PreAggregation: ", state); let state = state.new_level(); - result.println(&format!("name: {}", self.name), &state); - result.println(&format!("cube_name: {}", self.cube_name), &state); + result.println(&format!("name: {}", self.name()), &state); + result.println(&format!("cube_name: {}", self.cube_name()), &state); result.println(&format!("source:"), &state); - match self.source.as_ref() { + match self.source().as_ref() { PreAggregationSource::Single(table) => { let state = state.new_level(); result.println( @@ -126,11 +170,11 @@ impl PrettyPrint for PreAggregation { } } } - result.println(&format!("external: {}", self.external), &state); + result.println(&format!("external: {}", self.external()), &state); result.println( &format!( "granularity: {}", - self.granularity.clone().unwrap_or("None".to_string()) + self.granularity().clone().unwrap_or("None".to_string()) ), &state, ); @@ -138,7 +182,7 @@ impl PrettyPrint for PreAggregation { &format!( "-time_dimensions: {}", &self - .time_dimensions + .time_dimensions() .iter() .map(|(d, granularity)| format!( "({} {})", @@ -150,11 +194,11 @@ impl PrettyPrint for PreAggregation { &state, ); result.println( - &format!("-dimensions: {}", print_symbols(&self.dimensions)), + &format!("-dimensions: {}", print_symbols(self.dimensions())), &state, ); result.println( - &format!("-measures: {}", print_symbols(&self.measures)), + &format!("-measures: {}", print_symbols(self.measures())), &state, ); } diff --git a/rust/cubesqlplanner/cubesqlplanner/src/logical_plan/query.rs b/rust/cubesqlplanner/cubesqlplanner/src/logical_plan/query.rs index 9e1010dcfc590..62abb99fd23b8 100644 --- a/rust/cubesqlplanner/cubesqlplanner/src/logical_plan/query.rs +++ b/rust/cubesqlplanner/cubesqlplanner/src/logical_plan/query.rs @@ -1,49 +1,37 @@ use super::*; use cubenativeutils::CubeError; use std::rc::Rc; +use typed_builder::TypedBuilder; -#[derive(Clone)] -pub enum QuerySource { - LogicalJoin(Rc), - FullKeyAggregate(Rc), - PreAggregation(Rc), +#[derive(Clone, TypedBuilder)] +pub struct Query { + #[builder(default)] + multistage_members: Vec>, + schema: Rc, + filter: Rc, + modifers: Rc, + source: QuerySource, } -impl QuerySource { - fn as_plan_node(&self) -> PlanNode { - match self { - Self::LogicalJoin(item) => item.as_plan_node(), - Self::FullKeyAggregate(item) => item.as_plan_node(), - Self::PreAggregation(item) => item.as_plan_node(), - } +impl Query { + pub fn multistage_members(&self) -> &Vec> { + &self.multistage_members } - fn with_plan_node(&self, plan_node: PlanNode) -> Result { - Ok(match self { - Self::LogicalJoin(_) => Self::LogicalJoin(plan_node.into_logical_node()?), - Self::FullKeyAggregate(_) => Self::FullKeyAggregate(plan_node.into_logical_node()?), - Self::PreAggregation(_) => Self::PreAggregation(plan_node.into_logical_node()?), - }) + pub fn schema(&self) -> &Rc { + &self.schema } -} - -impl PrettyPrint for QuerySource { - fn pretty_print(&self, result: &mut PrettyPrintResult, state: &PrettyPrintState) { - match self { - QuerySource::LogicalJoin(join) => join.pretty_print(result, state), - QuerySource::FullKeyAggregate(full_key) => full_key.pretty_print(result, state), - QuerySource::PreAggregation(pre_aggregation) => { - pre_aggregation.pretty_print(result, state) - } - } + pub fn filter(&self) -> &Rc { + &self.filter + } + pub fn modifers(&self) -> &Rc { + &self.modifers + } + pub fn source(&self) -> &QuerySource { + &self.source + } + pub fn set_source(&mut self, source: QuerySource) { + self.source = source; } -} -#[derive(Clone)] -pub struct Query { - pub multistage_members: Vec>, - pub schema: Rc, - pub filter: Rc, - pub modifers: Rc, - pub source: QuerySource, } impl LogicalNode for Query { diff --git a/rust/cubesqlplanner/cubesqlplanner/src/logical_plan/query_source.rs b/rust/cubesqlplanner/cubesqlplanner/src/logical_plan/query_source.rs new file mode 100644 index 0000000000000..88c163a617928 --- /dev/null +++ b/rust/cubesqlplanner/cubesqlplanner/src/logical_plan/query_source.rs @@ -0,0 +1,5 @@ +use super::*; +use cubenativeutils::CubeError; +use std::rc::Rc; + +logical_source_enum!(QuerySource, [LogicalJoin, FullKeyAggregate, PreAggregation]); diff --git a/rust/cubesqlplanner/cubesqlplanner/src/logical_plan/schema.rs b/rust/cubesqlplanner/cubesqlplanner/src/logical_plan/schema.rs index afa9808098f21..7964642749069 100644 --- a/rust/cubesqlplanner/cubesqlplanner/src/logical_plan/schema.rs +++ b/rust/cubesqlplanner/cubesqlplanner/src/logical_plan/schema.rs @@ -3,6 +3,7 @@ use itertools::Itertools; use super::pretty_print::*; use crate::planner::sql_evaluator::MemberSymbol; use std::collections::HashSet; +use std::fmt; use std::rc::Rc; #[derive(Default, Clone)] @@ -13,6 +14,12 @@ pub struct LogicalSchema { pub multiplied_measures: HashSet, } +impl fmt::Debug for LogicalSchema { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + write!(f, "LogicalSchema") + } +} + impl LogicalSchema { pub fn set_time_dimensions(mut self, time_dimensions: Vec>) -> Self { self.time_dimensions = time_dimensions; diff --git a/rust/cubesqlplanner/cubesqlplanner/src/physical_plan_builder/builder.rs b/rust/cubesqlplanner/cubesqlplanner/src/physical_plan_builder/builder.rs index 5af384f4268d4..42b5117e80995 100644 --- a/rust/cubesqlplanner/cubesqlplanner/src/physical_plan_builder/builder.rs +++ b/rust/cubesqlplanner/cubesqlplanner/src/physical_plan_builder/builder.rs @@ -1,10 +1,12 @@ use super::context::PushDownBuilderContext; use super::{LogicalNodeProcessor, ProcessableNode}; use crate::logical_plan::*; +use crate::physical_plan_builder::context::MultiStageDimensionContext; use crate::plan::schema::QualifiedColumnName; use crate::plan::*; use crate::planner::query_properties::OrderByItem; use crate::planner::query_tools::QueryTools; +use crate::planner::sql_evaluator::sql_nodes::SqlNodesFactory; use crate::planner::sql_evaluator::MemberSymbol; use crate::planner::sql_evaluator::ReferencesBuilder; use crate::planner::sql_templates::PlanSqlTemplates; @@ -142,21 +144,49 @@ impl PhysicalPlanBuilder { Ok(()) } + pub(super) fn add_multistage_dimension_join( + &self, + dimension_schema: &Rc, + join_builder: &mut JoinBuilder, + ) -> Result<(), CubeError> { + let conditions = dimension_schema + .join_dimensions + .iter() + .map(|dim| -> Result<_, CubeError> { + let alias_in_cte = dimension_schema.schema.resolve_member_alias(&dim); + let sub_query_ref = Expr::Reference(QualifiedColumnName::new( + Some(dimension_schema.name.clone()), + alias_in_cte, + )); + + Ok(vec![(sub_query_ref, Expr::new_member(dim.clone()))]) + }) + .collect::, _>>()?; + + join_builder.left_join_table_reference( + dimension_schema.name.clone(), + dimension_schema.schema.clone(), + None, + JoinCondition::new_dimension_join(conditions, false), + ); + Ok(()) + } + pub(super) fn resolve_subquery_dimensions_references( &self, dimension_subqueries: &Vec>, references_builder: &ReferencesBuilder, - render_references: &mut HashMap, + context_factory: &mut SqlNodesFactory, ) -> Result<(), CubeError> { for dimension_subquery in dimension_subqueries.iter() { if let Some(dim_ref) = references_builder.find_reference_for_member( - &dimension_subquery - .measure_for_subquery_dimension - .full_name(), + &dimension_subquery.measure_for_subquery_dimension, &None, ) { - render_references - .insert(dimension_subquery.subquery_dimension.full_name(), dim_ref); + context_factory.add_render_reference( + dimension_subquery.subquery_dimension.full_name(), + dim_ref, + ); } else { return Err(CubeError::internal(format!( "Can't find source for subquery dimension {}", diff --git a/rust/cubesqlplanner/cubesqlplanner/src/physical_plan_builder/context.rs b/rust/cubesqlplanner/cubesqlplanner/src/physical_plan_builder/context.rs index 0fce71181cb3c..ce3189a5f57e1 100644 --- a/rust/cubesqlplanner/cubesqlplanner/src/physical_plan_builder/context.rs +++ b/rust/cubesqlplanner/cubesqlplanner/src/physical_plan_builder/context.rs @@ -7,6 +7,13 @@ use crate::planner::sql_evaluator::MemberSymbol; use std::collections::HashMap; use std::rc::Rc; +#[derive(Clone, Debug, Default)] +pub struct MultiStageDimensionContext { + pub name: String, + pub schema: Rc, + pub join_dimensions: Vec>, +} + #[derive(Clone, Debug, Default)] pub(super) struct PushDownBuilderContext { pub alias_prefix: Option, @@ -18,6 +25,8 @@ pub(super) struct PushDownBuilderContext { pub dimensions_query: bool, pub measure_subquery: bool, pub multi_stage_schemas: HashMap>, + pub multi_stage_dimension_schemas: HashMap, Rc>, + pub multi_stage_dimensions: Vec, } impl PushDownBuilderContext { @@ -41,6 +50,52 @@ impl PushDownBuilderContext { self.multi_stage_schemas.insert(name, schema); } + pub fn remove_multi_stage_dimensions(&mut self) { + self.multi_stage_dimensions = Vec::new(); + } + + pub fn add_multi_stage_dimension(&mut self, name: String) { + self.multi_stage_dimensions.push(name); + } + + pub fn get_multi_stage_dimensions( + &self, + ) -> Result>, CubeError> { + if self.multi_stage_dimensions.is_empty() { + return Ok(None); + } + let mut dimensions_to_resolve = self.multi_stage_dimensions.clone(); + dimensions_to_resolve.sort(); + if let Some(schema) = self + .multi_stage_dimension_schemas + .get(&dimensions_to_resolve) + { + Ok(Some(schema.clone())) + } else { + Err(CubeError::internal(format!( + "Cannot find source for resolve multi stage dimensions {}", + dimensions_to_resolve.join(", ") + ))) + } + } + + pub fn add_multi_stage_dimension_schema( + &mut self, + resolved_dimensions: Vec, + cte_name: String, + join_dimensions: Vec>, + schema: Rc, + ) { + self.multi_stage_dimension_schemas.insert( + resolved_dimensions, + Rc::new(MultiStageDimensionContext { + name: cte_name, + join_dimensions, + schema, + }), + ); + } + pub fn get_multi_stage_schema(&self, name: &str) -> Result, CubeError> { if let Some(schema) = self.multi_stage_schemas.get(name) { Ok(schema.clone()) diff --git a/rust/cubesqlplanner/cubesqlplanner/src/physical_plan_builder/processors/aggregate_multiplied_subquery.rs b/rust/cubesqlplanner/cubesqlplanner/src/physical_plan_builder/processors/aggregate_multiplied_subquery.rs index 709430f6b24de..c3da3703cd271 100644 --- a/rust/cubesqlplanner/cubesqlplanner/src/physical_plan_builder/processors/aggregate_multiplied_subquery.rs +++ b/rust/cubesqlplanner/cubesqlplanner/src/physical_plan_builder/processors/aggregate_multiplied_subquery.rs @@ -1,5 +1,5 @@ use super::super::{LogicalNodeProcessor, ProcessableNode, PushDownBuilderContext}; -use crate::logical_plan::{AggregateMultipliedSubquery, AggregateMultipliedSubquerySouce}; +use crate::logical_plan::{AggregateMultipliedSubquery, AggregateMultipliedSubquerySource}; use crate::physical_plan_builder::PhysicalPlanBuilder; use crate::plan::{ Expr, From, JoinBuilder, JoinCondition, MemberExpression, QualifiedColumnName, Select, @@ -7,7 +7,6 @@ use crate::plan::{ }; use crate::planner::sql_evaluator::ReferencesBuilder; use cubenativeutils::CubeError; -use std::collections::HashMap; use std::rc::Rc; pub struct AggregateMultipliedSubqueryProcessor<'a> { @@ -27,7 +26,6 @@ impl<'a> LogicalNodeProcessor<'a, AggregateMultipliedSubquery> aggregate_multiplied_subquery: &AggregateMultipliedSubquery, context: &PushDownBuilderContext, ) -> Result { - let mut render_references = HashMap::new(); let query_tools = self.builder.query_tools(); let keys_query = self.builder.process_node( aggregate_multiplied_subquery.keys_subquery.as_ref(), @@ -42,14 +40,17 @@ impl<'a> LogicalNodeProcessor<'a, AggregateMultipliedSubquery> let mut context_factory = context.make_sql_nodes_factory()?; let primary_keys_dimensions = &aggregate_multiplied_subquery .keys_subquery - .primary_keys_dimensions; - let pk_cube = aggregate_multiplied_subquery.keys_subquery.pk_cube.clone(); + .primary_keys_dimensions(); + let pk_cube = aggregate_multiplied_subquery + .keys_subquery + .pk_cube() + .clone(); let pk_cube_alias = pk_cube - .cube - .default_alias_with_prefix(&Some(format!("{}_key", pk_cube.cube.default_alias()))); + .cube() + .default_alias_with_prefix(&Some(format!("{}_key", pk_cube.cube().default_alias()))); match &aggregate_multiplied_subquery.source { - AggregateMultipliedSubquerySouce::Cube(cube) => { + AggregateMultipliedSubquerySource::Cube(cube) => { let conditions = primary_keys_dimensions .iter() .map(|dim| -> Result<_, CubeError> { @@ -64,7 +65,7 @@ impl<'a> LogicalNodeProcessor<'a, AggregateMultipliedSubquery> .collect::, _>>()?; join_builder.left_join_cube( - cube.cube.clone(), + cube.cube().clone(), Some(pk_cube_alias.clone()), JoinCondition::new_dimension_join(conditions, false), ); @@ -77,7 +78,7 @@ impl<'a> LogicalNodeProcessor<'a, AggregateMultipliedSubquery> )?; } } - AggregateMultipliedSubquerySouce::MeasureSubquery(measure_subquery) => { + AggregateMultipliedSubquerySource::MeasureSubquery(measure_subquery) => { let subquery = self .builder .process_node(measure_subquery.as_ref(), context)?; @@ -97,9 +98,8 @@ impl<'a> LogicalNodeProcessor<'a, AggregateMultipliedSubquery> Ok(vec![(keys_query_ref, measure_subquery_ref)]) }) .collect::, _>>()?; - let mut ungrouped_measure_references = HashMap::new(); for meas in aggregate_multiplied_subquery.schema.measures.iter() { - ungrouped_measure_references.insert( + context_factory.add_ungrouped_measure_reference( meas.full_name(), QualifiedColumnName::new( Some(pk_cube_alias.clone()), @@ -108,8 +108,6 @@ impl<'a> LogicalNodeProcessor<'a, AggregateMultipliedSubquery> ); } - context_factory.set_ungrouped_measure_references(ungrouped_measure_references); - join_builder.left_join_subselect( subquery, pk_cube_alias.clone(), @@ -126,16 +124,16 @@ impl<'a> LogicalNodeProcessor<'a, AggregateMultipliedSubquery> self.builder.resolve_subquery_dimensions_references( &aggregate_multiplied_subquery.dimension_subqueries, &references_builder, - &mut render_references, + &mut context_factory, )?; for member in aggregate_multiplied_subquery.schema.all_dimensions() { references_builder.resolve_references_for_member( member.clone(), &None, - &mut render_references, + context_factory.render_references_mut(), )?; - let alias = references_builder.resolve_alias_for_member(&member.full_name(), &None); + let alias = references_builder.resolve_alias_for_member(&member, &None); group_by.push(Expr::Member(MemberExpression::new(member.clone()))); select_builder.add_projection_member(&member, alias); } @@ -146,12 +144,12 @@ impl<'a> LogicalNodeProcessor<'a, AggregateMultipliedSubquery> if exists { if matches!( &aggregate_multiplied_subquery.source, - AggregateMultipliedSubquerySouce::Cube(_) + AggregateMultipliedSubquerySource::Cube(_) ) { references_builder.resolve_references_for_member( measure.clone(), &None, - &mut render_references, + context_factory.render_references_mut(), )?; } select_builder.add_projection_member(&measure, None); @@ -160,7 +158,6 @@ impl<'a> LogicalNodeProcessor<'a, AggregateMultipliedSubquery> } } select_builder.set_group_by(group_by); - context_factory.set_render_references(render_references); context_factory.set_rendered_as_multiplied_measures( aggregate_multiplied_subquery .schema diff --git a/rust/cubesqlplanner/cubesqlplanner/src/physical_plan_builder/processors/full_key_aggregate.rs b/rust/cubesqlplanner/cubesqlplanner/src/physical_plan_builder/processors/full_key_aggregate.rs index b49fa331e1169..38c240365260d 100644 --- a/rust/cubesqlplanner/cubesqlplanner/src/physical_plan_builder/processors/full_key_aggregate.rs +++ b/rust/cubesqlplanner/cubesqlplanner/src/physical_plan_builder/processors/full_key_aggregate.rs @@ -1,5 +1,5 @@ use super::super::{LogicalNodeProcessor, ProcessableNode, PushDownBuilderContext}; -use crate::logical_plan::{pretty_print, FullKeyAggregate, ResolvedMultipliedMeasures}; +use crate::logical_plan::{FullKeyAggregate, LogicalJoin, ResolvedMultipliedMeasures}; use crate::physical_plan_builder::PhysicalPlanBuilder; use crate::plan::{ Expr, From, FromSource, JoinBuilder, JoinCondition, QualifiedColumnName, SelectBuilder, @@ -39,7 +39,8 @@ impl FullKeyAggregateStrategy for KeysFullKeyAggregateStrategy<'_> { let mut data_queries = vec![]; let mut keys_context = context.clone(); keys_context.dimensions_query = true; - if let Some(resolved_multiplied_measures) = &full_key_aggregate.multiplied_measures_resolver + if let Some(resolved_multiplied_measures) = + full_key_aggregate.multiplied_measures_resolver() { match resolved_multiplied_measures { ResolvedMultipliedMeasures::ResolveMultipliedMeasures( @@ -84,16 +85,16 @@ impl FullKeyAggregateStrategy for KeysFullKeyAggregateStrategy<'_> { } } } - for multi_stage_ref in full_key_aggregate.multi_stage_subquery_refs.iter() { - let multi_stage_schema = context.get_multi_stage_schema(&multi_stage_ref.name)?; + for multi_stage_ref in full_key_aggregate.multi_stage_subquery_refs().iter() { + let multi_stage_schema = context.get_multi_stage_schema(multi_stage_ref.name())?; let multi_stage_source = SingleAliasedSource::new_from_table_reference( - multi_stage_ref.name.clone(), + multi_stage_ref.name().clone(), multi_stage_schema.clone(), None, ); let mut keys_select_builder = SelectBuilder::new(From::new(FromSource::Single(multi_stage_source.clone()))); - for dim in full_key_aggregate.schema.all_dimensions() { + for dim in full_key_aggregate.schema().all_dimensions() { let alias = multi_stage_schema.resolve_member_alias(dim); let reference = QualifiedColumnName::new(None, alias); keys_select_builder.add_projection_member_reference(dim, reference); @@ -110,10 +111,8 @@ impl FullKeyAggregateStrategy for KeysFullKeyAggregateStrategy<'_> { data_queries.push(data_select); } if data_queries.is_empty() { - return Err(CubeError::internal(format!( - "FullKeyAggregate should have at least one source: {}", - pretty_print(full_key_aggregate) - ))); + let empty_join = LogicalJoin::builder().build(); + return self.builder.process_node(&empty_join, context); } if data_queries.len() == 1 { @@ -129,8 +128,8 @@ impl FullKeyAggregateStrategy for KeysFullKeyAggregateStrategy<'_> { let references_builder = ReferencesBuilder::new(keys_from.clone()); let mut keys_select_builder = SelectBuilder::new(keys_from); - for member in full_key_aggregate.schema.all_dimensions() { - let alias = references_builder.resolve_alias_for_member(&member.full_name(), &None); + for member in full_key_aggregate.schema().all_dimensions() { + let alias = references_builder.resolve_alias_for_member(&member, &None); if alias.is_none() { return Err(CubeError::internal(format!( "Source for {} not found in full key aggregate subqueries", @@ -153,7 +152,7 @@ impl FullKeyAggregateStrategy for KeysFullKeyAggregateStrategy<'_> { for (i, query) in data_queries.into_iter().enumerate() { let query_alias = format!("q_{}", i); let conditions = full_key_aggregate - .schema + .schema() .all_dimensions() .map(|dim| -> Result<_, CubeError> { let alias_in_keys_query = keys_select.schema().resolve_member_alias(dim); @@ -201,7 +200,8 @@ impl FullKeyAggregateStrategy for InnerJoinFullKeyAggregateStrategy<'_> { ) -> Result, CubeError> { let query_tools = self.builder.query_tools(); let mut data_queries = vec![]; - if let Some(resolved_multiplied_measures) = &full_key_aggregate.multiplied_measures_resolver + if let Some(resolved_multiplied_measures) = + full_key_aggregate.multiplied_measures_resolver() { match resolved_multiplied_measures { ResolvedMultipliedMeasures::ResolveMultipliedMeasures( @@ -235,10 +235,10 @@ impl FullKeyAggregateStrategy for InnerJoinFullKeyAggregateStrategy<'_> { } } - for multi_stage_ref in full_key_aggregate.multi_stage_subquery_refs.iter() { - let multi_stage_schema = context.get_multi_stage_schema(&multi_stage_ref.name)?; + for multi_stage_ref in full_key_aggregate.multi_stage_subquery_refs().iter() { + let multi_stage_schema = context.get_multi_stage_schema(multi_stage_ref.name())?; let multi_stage_source = SingleAliasedSource::new_from_table_reference( - multi_stage_ref.name.clone(), + multi_stage_ref.name().clone(), multi_stage_schema.clone(), None, ); @@ -251,10 +251,8 @@ impl FullKeyAggregateStrategy for InnerJoinFullKeyAggregateStrategy<'_> { } if data_queries.is_empty() { - return Err(CubeError::internal(format!( - "FullKeyAggregate should have at least one source: {}", - pretty_print(full_key_aggregate) - ))); + let empty_join = LogicalJoin::builder().build(); + return self.builder.process_node(&empty_join, context); } if data_queries.len() == 1 { @@ -270,7 +268,7 @@ impl FullKeyAggregateStrategy for InnerJoinFullKeyAggregateStrategy<'_> { let prev_alias = format!("q_{}", i); let query_alias = format!("q_{}", i + 1); let conditions = full_key_aggregate - .schema + .schema() .all_dimensions() .map(|dim| -> Result<_, CubeError> { let alias_in_prev_query = data_queries[i].schema().resolve_member_alias(dim); @@ -316,7 +314,7 @@ impl<'a> LogicalNodeProcessor<'a, FullKeyAggregate> for FullKeyAggregateProcesso context: &PushDownBuilderContext, ) -> Result { let strategy: Rc = - if full_key_aggregate.schema.has_dimensions() { + if full_key_aggregate.schema().has_dimensions() { KeysFullKeyAggregateStrategy::new(self.builder) } else { InnerJoinFullKeyAggregateStrategy::new(self.builder) diff --git a/rust/cubesqlplanner/cubesqlplanner/src/physical_plan_builder/processors/full_key_aggregate_query.rs b/rust/cubesqlplanner/cubesqlplanner/src/physical_plan_builder/processors/full_key_aggregate_query.rs deleted file mode 100644 index 06d91dacd7248..0000000000000 --- a/rust/cubesqlplanner/cubesqlplanner/src/physical_plan_builder/processors/full_key_aggregate_query.rs +++ /dev/null @@ -1,99 +0,0 @@ -use super::super::{LogicalNodeProcessor, ProcessableNode, PushDownBuilderContext}; -use crate::logical_plan::{FullKeyAggregateQuery, SimpleQuery, SimpleQuerySource}; -use crate::physical_plan_builder::PhysicalPlanBuilder; -use crate::plan::{Expr, Filter, MemberExpression, QueryPlan, Select, SelectBuilder}; -use crate::planner::query_tools::QueryTools; -use crate::planner::sql_evaluator::ReferencesBuilder; -use crate::planner::sql_templates::PlanSqlTemplates; -use crate::planner::{BaseMember, MemberSymbolRef}; -use cubenativeutils::CubeError; -use itertools::Itertools; -use std::collections::HashMap; -use std::rc::Rc; - -pub struct FullKeyAggregateQueryProcessor<'a> { - builder: &'a PhysicalPlanBuilder, -} - -impl<'a> LogicalNodeProcessor<'a, FullKeyAggregateQuery> for FullKeyAggregateQueryProcessor<'a> { - type PhysycalNode = Rc