From bb748c047923e6b26fe330cc2f564f5f566c22ad Mon Sep 17 00:00:00 2001 From: Konstantin Burkalev Date: Mon, 11 Aug 2025 17:46:37 +0300 Subject: [PATCH 01/11] feat(tesseract): Support time series queries in Databricks --- .../src/DatabricksQuery.ts | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/packages/cubejs-databricks-jdbc-driver/src/DatabricksQuery.ts b/packages/cubejs-databricks-jdbc-driver/src/DatabricksQuery.ts index b0da4374d9e2c..def6b9e2baf4e 100644 --- a/packages/cubejs-databricks-jdbc-driver/src/DatabricksQuery.ts +++ b/packages/cubejs-databricks-jdbc-driver/src/DatabricksQuery.ts @@ -178,6 +178,16 @@ export class DatabricksQuery extends BaseQuery { templates.expressions.interval_single_date_part = 'INTERVAL \'{{ num }}\' {{ date_part }}'; templates.quotes.identifiers = '`'; templates.quotes.escape = '``'; + templates.statements.time_series_select = 'SELECT date_from::timestamp AS `date_from`,\n' + + 'date_to::timestamp AS `date_to` \n' + + 'FROM(\n' + + ' VALUES ' + + '{% for time_item in seria %}' + + '(\'{{ time_item | join(\'\\\', \\\'\') }}\')' + + '{% if not loop.last %}, {% endif %}' + + '{% endfor %}' + + ') AS dates (date_from, date_to)'; + // TODO: Databricks has `TIMESTAMP_NTZ` with logic similar to Pg's `TIMESTAMP` // but that requires Runtime 13.3+. Should this be enabled? // templates.types.timestamp = 'TIMESTAMP_NTZ'; From dd81ce759475201c81fe67d80bbcc65e2edcea09 Mon Sep 17 00:00:00 2001 From: Konstantin Burkalev Date: Mon, 11 Aug 2025 18:36:49 +0300 Subject: [PATCH 02/11] run databricks drivers-tests with tesseract --- .github/workflows/drivers-tests.yml | 2 + .../fixtures/databricks-jdbc.json | 43 +++++++++++++++++++ 2 files changed, 45 insertions(+) diff --git a/.github/workflows/drivers-tests.yml b/.github/workflows/drivers-tests.yml index 263a61fbc8045..7f16a79527882 100644 --- a/.github/workflows/drivers-tests.yml +++ b/.github/workflows/drivers-tests.yml @@ -273,6 +273,8 @@ jobs: use_tesseract_sql_planner: true - database: athena-export-bucket-s3 use_tesseract_sql_planner: true + - database: databricks-jdbc + use_tesseract_sql_planner: true fail-fast: false steps: diff --git a/packages/cubejs-testing-drivers/fixtures/databricks-jdbc.json b/packages/cubejs-testing-drivers/fixtures/databricks-jdbc.json index e2c62e8eaf59e..3e446bb1cc41f 100644 --- a/packages/cubejs-testing-drivers/fixtures/databricks-jdbc.json +++ b/packages/cubejs-testing-drivers/fixtures/databricks-jdbc.json @@ -235,5 +235,48 @@ "SQL API: Nested Rollup with aliases", "SQL API: Nested Rollup over asteriks", "SQL API: Extended nested Rollup over asterisk" + ], + "tesseractSkip": [ + "must download query from the data source via memory", + "must download query from the data source via stream", + "for the Customers.RollingExternal", + "for the Customers.RollingInternal", + "for the ECommerce.SimpleAnalysisExternal", + "for the ECommerce.SimpleAnalysisInternal", + "for the ECommerce.TimeAnalysisInternal", + "for the ECommerce.TimeAnalysisExternal", + "querying Products: dimensions -- doesn't work wo ordering", + "querying ECommerce: total quantity, avg discount, total sales, total profit by product + order + total -- rounding in athena", + "querying ECommerce: total sales, total profit by month + order (date) + total -- doesn't work with the BigQuery", + "querying ECommerce: total quantity, avg discount, total sales, total profit by product + order + total -- noisy test", + "querying custom granularities ECommerce: count by three_months_by_march + no dimension", + "querying custom granularities ECommerce: count by three_months_by_march + dimension", + "SQL API: SQL push down push to cube quoted alias", + "SQL API: Complex Rollup", + "SQL API: Simple Rollup", + "SQL API: Rollup over exprs", + "SQL API: Rollup with aliases", + "SQL API: Nested Rollup", + "SQL API: Nested Rollup with aliases", + "SQL API: Nested Rollup over asterisk", + "SQL API: Rolling Window YTD (year + month + day + date_trunc equal)", + "SQL API: Rolling Window YTD (year + month + day + date_trunc IN)", + + "---- Different results comparing to baseQuery version. Need to investigate ----", + "querying ECommerce: dimensions", + "querying ECommerce: dimensions + order", + "querying ECommerce: dimensions + limit", + "querying ECommerce: dimensions + total", + "querying ECommerce: dimensions + order + limit + total", + "querying ECommerce: dimensions + order + total + offset", + "querying ECommerce: dimensions + order + limit + total + offset", + "filtering ECommerce: contains dimensions, first", + "filtering ECommerce: contains dimensions, second", + "filtering ECommerce: startsWith + dimensions, first", + "filtering ECommerce: startsWith + dimensions, second", + "filtering ECommerce: endsWith + dimensions, first", + "filtering ECommerce: endsWith + dimensions, second", + "querying BigECommerce: rolling window YTD (month + week)", + "querying BigECommerce: rolling window YTD (month + week + no gran)" ] } From 60884fb5152038af6aaac03cdecfecb5b3ab1f80 Mon Sep 17 00:00:00 2001 From: Konstantin Burkalev Date: Mon, 11 Aug 2025 18:37:07 +0300 Subject: [PATCH 03/11] fix templates.statements.generated_time_series_select --- .../src/DatabricksQuery.ts | 21 ++++++++++++------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/packages/cubejs-databricks-jdbc-driver/src/DatabricksQuery.ts b/packages/cubejs-databricks-jdbc-driver/src/DatabricksQuery.ts index def6b9e2baf4e..7b7676727345d 100644 --- a/packages/cubejs-databricks-jdbc-driver/src/DatabricksQuery.ts +++ b/packages/cubejs-databricks-jdbc-driver/src/DatabricksQuery.ts @@ -179,14 +179,19 @@ export class DatabricksQuery extends BaseQuery { templates.quotes.identifiers = '`'; templates.quotes.escape = '``'; templates.statements.time_series_select = 'SELECT date_from::timestamp AS `date_from`,\n' + - 'date_to::timestamp AS `date_to` \n' + - 'FROM(\n' + - ' VALUES ' + - '{% for time_item in seria %}' + - '(\'{{ time_item | join(\'\\\', \\\'\') }}\')' + - '{% if not loop.last %}, {% endif %}' + - '{% endfor %}' + - ') AS dates (date_from, date_to)'; + 'date_to::timestamp AS `date_to` \n' + + 'FROM(\n' + + ' VALUES ' + + '{% for time_item in seria %}' + + '(\'{{ time_item | join(\'\\\', \\\'\') }}\')' + + '{% if not loop.last %}, {% endif %}' + + '{% endfor %}' + + ') AS dates (date_from, date_to)'; + templates.statements.generated_time_series_select = 'SELECT d AS date_from,\n' + + '(d + INTERVAL {{ granularity }}) - INTERVAL 1 MILLISECOND AS date_to\n' + + ' FROM (SELECT explode(sequence(\n' + + ' from_utc_timestamp({{ start }}, \'UTC\'), from_utc_timestamp({{ end }}, \'UTC\'), INTERVAL {{ granularity }}\n' + + ' )) AS d)'; // TODO: Databricks has `TIMESTAMP_NTZ` with logic similar to Pg's `TIMESTAMP` // but that requires Runtime 13.3+. Should this be enabled? From 9dd4c29520cdb952c3555faa263de7eed0184ad3 Mon Sep 17 00:00:00 2001 From: Konstantin Burkalev Date: Mon, 11 Aug 2025 21:15:09 +0300 Subject: [PATCH 04/11] fix templates.statements.generated_time_series_with_cte_range_source --- .../src/DatabricksQuery.ts | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/packages/cubejs-databricks-jdbc-driver/src/DatabricksQuery.ts b/packages/cubejs-databricks-jdbc-driver/src/DatabricksQuery.ts index 7b7676727345d..9e8aa43150190 100644 --- a/packages/cubejs-databricks-jdbc-driver/src/DatabricksQuery.ts +++ b/packages/cubejs-databricks-jdbc-driver/src/DatabricksQuery.ts @@ -192,6 +192,17 @@ export class DatabricksQuery extends BaseQuery { ' FROM (SELECT explode(sequence(\n' + ' from_utc_timestamp({{ start }}, \'UTC\'), from_utc_timestamp({{ end }}, \'UTC\'), INTERVAL {{ granularity }}\n' + ' )) AS d)'; + templates.statements.generated_time_series_with_cte_range_source = + 'SELECT d AS date_from,\n' + + '(d + INTERVAL {{ granularity }}) - INTERVAL 1 MILLISECOND AS date_to\n' + + 'FROM {{ range_source }}\n' + + 'LATERAL VIEW explode(\n' + + ' sequence(\n' + + ' CAST({{ min_name }} AS TIMESTAMP),\n' + + ' CAST({{ max_name }} AS TIMESTAMP),\n' + + ' INTERVAL {{ granularity }}\n' + + ' )\n' + + ') dates AS d'; // TODO: Databricks has `TIMESTAMP_NTZ` with logic similar to Pg's `TIMESTAMP` // but that requires Runtime 13.3+. Should this be enabled? From e0609dc6aceba606d5a2a5f41b84f7f7e747b583 Mon Sep 17 00:00:00 2001 From: Konstantin Burkalev Date: Mon, 11 Aug 2025 21:22:42 +0300 Subject: [PATCH 05/11] enable supportGeneratedSeriesForCustomTd --- packages/cubejs-databricks-jdbc-driver/src/DatabricksQuery.ts | 4 ++++ packages/cubejs-testing-drivers/fixtures/databricks-jdbc.json | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/packages/cubejs-databricks-jdbc-driver/src/DatabricksQuery.ts b/packages/cubejs-databricks-jdbc-driver/src/DatabricksQuery.ts index 9e8aa43150190..ac08b4328d099 100644 --- a/packages/cubejs-databricks-jdbc-driver/src/DatabricksQuery.ts +++ b/packages/cubejs-databricks-jdbc-driver/src/DatabricksQuery.ts @@ -161,6 +161,10 @@ export class DatabricksQuery extends BaseQuery { return 120; } + public supportGeneratedSeriesForCustomTd() { + return true; + } + public sqlTemplates() { const templates = super.sqlTemplates(); templates.functions.CURRENTDATE = 'CURRENT_DATE'; diff --git a/packages/cubejs-testing-drivers/fixtures/databricks-jdbc.json b/packages/cubejs-testing-drivers/fixtures/databricks-jdbc.json index 3e446bb1cc41f..06430be25943e 100644 --- a/packages/cubejs-testing-drivers/fixtures/databricks-jdbc.json +++ b/packages/cubejs-testing-drivers/fixtures/databricks-jdbc.json @@ -262,7 +262,7 @@ "SQL API: Rolling Window YTD (year + month + day + date_trunc equal)", "SQL API: Rolling Window YTD (year + month + day + date_trunc IN)", - "---- Different results comparing to baseQuery version. Need to investigate ----", + "---- Different results comparing to baseQuery version. Need to investigate ----", "querying ECommerce: dimensions", "querying ECommerce: dimensions + order", "querying ECommerce: dimensions + limit", From f45b44c42a414587cb5c85ebef95b5c78b4c4145 Mon Sep 17 00:00:00 2001 From: Konstantin Burkalev Date: Mon, 11 Aug 2025 22:36:32 +0300 Subject: [PATCH 06/11] add snapshot: querying BigECommerce: rolling window by 2 day without date range --- .../databricks-jdbc-full.test.ts.snap | 95 ++++++++++++++++--- 1 file changed, 80 insertions(+), 15 deletions(-) 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 fce072a38c3cb..f81864fb3ed64 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 @@ -9060,6 +9060,21 @@ Array [ ] `; +exports[`Queries with the @cubejs-backend/databricks-jdbc-driver querying BigECommerce: filtering with possible casts 1`] = ` +Array [ + Object { + "BigECommerce.orderDate": "2020-01-01T00:00:00.000", + "BigECommerce.orderDate.month": "2020-01-01T00:00:00.000", + "BigECommerce.totalSales": 48.896, + }, + Object { + "BigECommerce.orderDate": "2020-12-01T00:00:00.000", + "BigECommerce.orderDate.month": "2020-12-01T00:00:00.000", + "BigECommerce.totalSales": 232.88, + }, +] +`; + exports[`Queries with the @cubejs-backend/databricks-jdbc-driver querying BigECommerce: null boolean 1`] = ` Array [ Object { @@ -10955,6 +10970,71 @@ Array [ ] `; +exports[`Queries with the @cubejs-backend/databricks-jdbc-driver querying BigECommerce: rolling window by 2 day without date range 1`] = ` +Array [ + Object { + "BigECommerce.orderDate": "2020-01-01T00:00:00.000", + "BigECommerce.orderDate.month": "2020-01-01T00:00:00.000", + "BigECommerce.rollingCountBy2Day": null, + }, + Object { + "BigECommerce.orderDate": "2020-02-01T00:00:00.000", + "BigECommerce.orderDate.month": "2020-02-01T00:00:00.000", + "BigECommerce.rollingCountBy2Day": null, + }, + Object { + "BigECommerce.orderDate": "2020-03-01T00:00:00.000", + "BigECommerce.orderDate.month": "2020-03-01T00:00:00.000", + "BigECommerce.rollingCountBy2Day": null, + }, + Object { + "BigECommerce.orderDate": "2020-04-01T00:00:00.000", + "BigECommerce.orderDate.month": "2020-04-01T00:00:00.000", + "BigECommerce.rollingCountBy2Day": null, + }, + Object { + "BigECommerce.orderDate": "2020-05-01T00:00:00.000", + "BigECommerce.orderDate.month": "2020-05-01T00:00:00.000", + "BigECommerce.rollingCountBy2Day": null, + }, + Object { + "BigECommerce.orderDate": "2020-06-01T00:00:00.000", + "BigECommerce.orderDate.month": "2020-06-01T00:00:00.000", + "BigECommerce.rollingCountBy2Day": null, + }, + Object { + "BigECommerce.orderDate": "2020-07-01T00:00:00.000", + "BigECommerce.orderDate.month": "2020-07-01T00:00:00.000", + "BigECommerce.rollingCountBy2Day": null, + }, + Object { + "BigECommerce.orderDate": "2020-08-01T00:00:00.000", + "BigECommerce.orderDate.month": "2020-08-01T00:00:00.000", + "BigECommerce.rollingCountBy2Day": null, + }, + Object { + "BigECommerce.orderDate": "2020-09-01T00:00:00.000", + "BigECommerce.orderDate.month": "2020-09-01T00:00:00.000", + "BigECommerce.rollingCountBy2Day": null, + }, + Object { + "BigECommerce.orderDate": "2020-10-01T00:00:00.000", + "BigECommerce.orderDate.month": "2020-10-01T00:00:00.000", + "BigECommerce.rollingCountBy2Day": "1", + }, + Object { + "BigECommerce.orderDate": "2020-11-01T00:00:00.000", + "BigECommerce.orderDate.month": "2020-11-01T00:00:00.000", + "BigECommerce.rollingCountBy2Day": null, + }, + Object { + "BigECommerce.orderDate": "2020-12-01T00:00:00.000", + "BigECommerce.orderDate.month": "2020-12-01T00:00:00.000", + "BigECommerce.rollingCountBy2Day": null, + }, +] +`; + exports[`Queries with the @cubejs-backend/databricks-jdbc-driver querying BigECommerce: rolling window by 2 month 1`] = ` Array [ Object { @@ -15980,18 +16060,3 @@ Array [ }, ] `; - -exports[`Queries with the @cubejs-backend/databricks-jdbc-driver querying BigECommerce: filtering with possible casts 1`] = ` -Array [ - Object { - "BigECommerce.orderDate": "2020-01-01T00:00:00.000", - "BigECommerce.orderDate.month": "2020-01-01T00:00:00.000", - "BigECommerce.totalSales": 48.896, - }, - Object { - "BigECommerce.orderDate": "2020-12-01T00:00:00.000", - "BigECommerce.orderDate.month": "2020-12-01T00:00:00.000", - "BigECommerce.totalSales": 232.88, - }, -] -`; From 5b3872971162cee6cc0e9a65d4a83ebc22e79ad8 Mon Sep 17 00:00:00 2001 From: Konstantin Burkalev Date: Mon, 11 Aug 2025 22:41:12 +0300 Subject: [PATCH 07/11] add snapshot: querying BigECommerce: rolling window by 2 month without date range --- .../databricks-jdbc-full.test.ts.snap | 65 +++++++++++++++++++ 1 file changed, 65 insertions(+) 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 f81864fb3ed64..fca52b69389d4 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 @@ -11100,6 +11100,71 @@ Array [ ] `; +exports[`Queries with the @cubejs-backend/databricks-jdbc-driver querying BigECommerce: rolling window by 2 month without date range 1`] = ` +Array [ + Object { + "BigECommerce.orderDate": "2020-01-01T00:00:00.000", + "BigECommerce.orderDate.month": "2020-01-01T00:00:00.000", + "BigECommerce.rollingCountBy2Month": "2", + }, + Object { + "BigECommerce.orderDate": "2020-02-01T00:00:00.000", + "BigECommerce.orderDate.month": "2020-02-01T00:00:00.000", + "BigECommerce.rollingCountBy2Month": "3", + }, + Object { + "BigECommerce.orderDate": "2020-03-01T00:00:00.000", + "BigECommerce.orderDate.month": "2020-03-01T00:00:00.000", + "BigECommerce.rollingCountBy2Month": "3", + }, + Object { + "BigECommerce.orderDate": "2020-04-01T00:00:00.000", + "BigECommerce.orderDate.month": "2020-04-01T00:00:00.000", + "BigECommerce.rollingCountBy2Month": "3", + }, + Object { + "BigECommerce.orderDate": "2020-05-01T00:00:00.000", + "BigECommerce.orderDate.month": "2020-05-01T00:00:00.000", + "BigECommerce.rollingCountBy2Month": "6", + }, + Object { + "BigECommerce.orderDate": "2020-06-01T00:00:00.000", + "BigECommerce.orderDate.month": "2020-06-01T00:00:00.000", + "BigECommerce.rollingCountBy2Month": "12", + }, + Object { + "BigECommerce.orderDate": "2020-07-01T00:00:00.000", + "BigECommerce.orderDate.month": "2020-07-01T00:00:00.000", + "BigECommerce.rollingCountBy2Month": "7", + }, + Object { + "BigECommerce.orderDate": "2020-08-01T00:00:00.000", + "BigECommerce.orderDate.month": "2020-08-01T00:00:00.000", + "BigECommerce.rollingCountBy2Month": null, + }, + Object { + "BigECommerce.orderDate": "2020-09-01T00:00:00.000", + "BigECommerce.orderDate.month": "2020-09-01T00:00:00.000", + "BigECommerce.rollingCountBy2Month": "6", + }, + Object { + "BigECommerce.orderDate": "2020-10-01T00:00:00.000", + "BigECommerce.orderDate.month": "2020-10-01T00:00:00.000", + "BigECommerce.rollingCountBy2Month": "10", + }, + Object { + "BigECommerce.orderDate": "2020-11-01T00:00:00.000", + "BigECommerce.orderDate.month": "2020-11-01T00:00:00.000", + "BigECommerce.rollingCountBy2Month": "13", + }, + Object { + "BigECommerce.orderDate": "2020-12-01T00:00:00.000", + "BigECommerce.orderDate.month": "2020-12-01T00:00:00.000", + "BigECommerce.rollingCountBy2Month": "16", + }, +] +`; + exports[`Queries with the @cubejs-backend/databricks-jdbc-driver querying BigECommerce: rolling window by 2 week 1`] = ` Array [ Object { From cd36023f2fc7f9393915c5088926319a22729548 Mon Sep 17 00:00:00 2001 From: Konstantin Burkalev Date: Mon, 11 Aug 2025 22:47:15 +0300 Subject: [PATCH 08/11] update snapshot: querying BigECommerce: rolling window YTD without date range --- .../databricks-jdbc-full.test.ts.snap | 65 +++++++++++++++++++ 1 file changed, 65 insertions(+) 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 fca52b69389d4..6892ec9bc8c3e 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 @@ -10897,6 +10897,71 @@ Array [ ] `; +exports[`Queries with the @cubejs-backend/databricks-jdbc-driver querying BigECommerce: rolling window YTD without date range 1`] = ` +Array [ + Object { + "BigECommerce.orderDate": "2020-01-01T00:00:00.000", + "BigECommerce.orderDate.month": "2020-01-01T00:00:00.000", + "BigECommerce.rollingCountYTD": "2", + }, + Object { + "BigECommerce.orderDate": "2020-02-01T00:00:00.000", + "BigECommerce.orderDate.month": "2020-02-01T00:00:00.000", + "BigECommerce.rollingCountYTD": "3", + }, + Object { + "BigECommerce.orderDate": "2020-03-01T00:00:00.000", + "BigECommerce.orderDate.month": "2020-03-01T00:00:00.000", + "BigECommerce.rollingCountYTD": "5", + }, + Object { + "BigECommerce.orderDate": "2020-04-01T00:00:00.000", + "BigECommerce.orderDate.month": "2020-04-01T00:00:00.000", + "BigECommerce.rollingCountYTD": "6", + }, + Object { + "BigECommerce.orderDate": "2020-05-01T00:00:00.000", + "BigECommerce.orderDate.month": "2020-05-01T00:00:00.000", + "BigECommerce.rollingCountYTD": "11", + }, + Object { + "BigECommerce.orderDate": "2020-06-01T00:00:00.000", + "BigECommerce.orderDate.month": "2020-06-01T00:00:00.000", + "BigECommerce.rollingCountYTD": "18", + }, + Object { + "BigECommerce.orderDate": "2020-07-01T00:00:00.000", + "BigECommerce.orderDate.month": "2020-07-01T00:00:00.000", + "BigECommerce.rollingCountYTD": "18", + }, + Object { + "BigECommerce.orderDate": "2020-08-01T00:00:00.000", + "BigECommerce.orderDate.month": "2020-08-01T00:00:00.000", + "BigECommerce.rollingCountYTD": "18", + }, + Object { + "BigECommerce.orderDate": "2020-09-01T00:00:00.000", + "BigECommerce.orderDate.month": "2020-09-01T00:00:00.000", + "BigECommerce.rollingCountYTD": "24", + }, + Object { + "BigECommerce.orderDate": "2020-10-01T00:00:00.000", + "BigECommerce.orderDate.month": "2020-10-01T00:00:00.000", + "BigECommerce.rollingCountYTD": "28", + }, + Object { + "BigECommerce.orderDate": "2020-11-01T00:00:00.000", + "BigECommerce.orderDate.month": "2020-11-01T00:00:00.000", + "BigECommerce.rollingCountYTD": "37", + }, + Object { + "BigECommerce.orderDate": "2020-12-01T00:00:00.000", + "BigECommerce.orderDate.month": "2020-12-01T00:00:00.000", + "BigECommerce.rollingCountYTD": "44", + }, +] +`; + exports[`Queries with the @cubejs-backend/databricks-jdbc-driver querying BigECommerce: rolling window YTD without granularity 1`] = ` Array [ Object { From 5e681d6b3772594a56ce21805c8936e1ab0208fc Mon Sep 17 00:00:00 2001 From: Konstantin Burkalev Date: Mon, 11 Aug 2025 22:53:36 +0300 Subject: [PATCH 09/11] add snapshot: querying BigECommerce with Retail Calendar --- .../databricks-jdbc-full.test.ts.snap | 165 ++++++++++++++++++ 1 file changed, 165 insertions(+) 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 6892ec9bc8c3e..68931fb84e72d 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 @@ -9060,6 +9060,171 @@ Array [ ] `; +exports[`Queries with the @cubejs-backend/databricks-jdbc-driver 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", + }, + 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", + }, + 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", + }, + 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", + }, +] +`; + +exports[`Queries with the @cubejs-backend/databricks-jdbc-driver querying BigECommerce with Retail Calendar: totalCountRetailWeekAgo 1`] = ` +Array [ + Object { + "BigECommerce.count": "1", + "BigECommerce.totalCountRetailWeekAgo": "1", + "RetailCalendar.retail_date": "2020-03-22", + "RetailCalendar.retail_date.week": "2020-03-22", + }, + Object { + "BigECommerce.count": "1", + "BigECommerce.totalCountRetailWeekAgo": "2", + "RetailCalendar.retail_date": "2020-05-31", + "RetailCalendar.retail_date.week": "2020-05-31", + }, + Object { + "BigECommerce.count": "2", + "BigECommerce.totalCountRetailWeekAgo": "1", + "RetailCalendar.retail_date": "2020-06-07", + "RetailCalendar.retail_date.week": "2020-06-07", + }, + Object { + "BigECommerce.count": "2", + "BigECommerce.totalCountRetailWeekAgo": "2", + "RetailCalendar.retail_date": "2020-06-14", + "RetailCalendar.retail_date.week": "2020-06-14", + }, + Object { + "BigECommerce.count": "2", + "BigECommerce.totalCountRetailWeekAgo": "2", + "RetailCalendar.retail_date": "2020-06-21", + "RetailCalendar.retail_date.week": "2020-06-21", + }, + Object { + "BigECommerce.count": "1", + "BigECommerce.totalCountRetailWeekAgo": "2", + "RetailCalendar.retail_date": "2020-09-06", + "RetailCalendar.retail_date.week": "2020-09-06", + }, + Object { + "BigECommerce.count": "2", + "BigECommerce.totalCountRetailWeekAgo": "1", + "RetailCalendar.retail_date": "2020-09-13", + "RetailCalendar.retail_date.week": "2020-09-13", + }, + Object { + "BigECommerce.count": "1", + "BigECommerce.totalCountRetailWeekAgo": "2", + "RetailCalendar.retail_date": "2020-09-20", + "RetailCalendar.retail_date.week": "2020-09-20", + }, + Object { + "BigECommerce.count": "2", + "BigECommerce.totalCountRetailWeekAgo": "1", + "RetailCalendar.retail_date": "2020-10-18", + "RetailCalendar.retail_date.week": "2020-10-18", + }, + Object { + "BigECommerce.count": "1", + "BigECommerce.totalCountRetailWeekAgo": "2", + "RetailCalendar.retail_date": "2020-10-25", + "RetailCalendar.retail_date.week": "2020-10-25", + }, + Object { + "BigECommerce.count": "3", + "BigECommerce.totalCountRetailWeekAgo": "1", + "RetailCalendar.retail_date": "2020-11-01", + "RetailCalendar.retail_date.week": "2020-11-01", + }, + Object { + "BigECommerce.count": "2", + "BigECommerce.totalCountRetailWeekAgo": "3", + "RetailCalendar.retail_date": "2020-11-08", + "RetailCalendar.retail_date.week": "2020-11-08", + }, + Object { + "BigECommerce.count": "3", + "BigECommerce.totalCountRetailWeekAgo": "2", + "RetailCalendar.retail_date": "2020-11-15", + "RetailCalendar.retail_date.week": "2020-11-15", + }, + Object { + "BigECommerce.count": "1", + "BigECommerce.totalCountRetailWeekAgo": "3", + "RetailCalendar.retail_date": "2020-11-22", + "RetailCalendar.retail_date.week": "2020-11-22", + }, + Object { + "BigECommerce.count": "3", + "BigECommerce.totalCountRetailWeekAgo": "1", + "RetailCalendar.retail_date": "2020-11-29", + "RetailCalendar.retail_date.week": "2020-11-29", + }, + Object { + "BigECommerce.count": "2", + "BigECommerce.totalCountRetailWeekAgo": "2", + "RetailCalendar.retail_date": "2020-12-20", + "RetailCalendar.retail_date.week": "2020-12-20", + }, +] +`; + +exports[`Queries with the @cubejs-backend/databricks-jdbc-driver querying BigECommerce with Retail Calendar: totalCountRetailYearAgo 1`] = ` +Array [ + Object { + "BigECommerce.count": "42", + "BigECommerce.totalCountRetailYearAgo": "2", + "RetailCalendar.retail_date": "2020-02-02", + "RetailCalendar.retail_date.year": "2020-02-02", + }, +] +`; + exports[`Queries with the @cubejs-backend/databricks-jdbc-driver querying BigECommerce: filtering with possible casts 1`] = ` Array [ Object { From dee0e4063b09f78611a2c60e3a608b6b67470232 Mon Sep 17 00:00:00 2001 From: Konstantin Burkalev Date: Mon, 11 Aug 2025 23:02:39 +0300 Subject: [PATCH 10/11] add snapshot: querying custom granularities ECommerce: count by two_mo_by_feb + no dimension + rollingCountByLeading without date range --- .../databricks-jdbc-full.test.ts.snap | 40 +++++++++++++++++++ 1 file changed, 40 insertions(+) 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 68931fb84e72d..fbc612e51427d 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 @@ -16276,6 +16276,46 @@ Array [ ] `; +exports[`Queries with the @cubejs-backend/databricks-jdbc-driver querying custom granularities ECommerce: count by two_mo_by_feb + no dimension + rollingCountByLeading without date range 1`] = ` +Array [ + Object { + "ECommerce.customOrderDateNoPreAgg": "2019-12-01T10:00:00.000", + "ECommerce.customOrderDateNoPreAgg.two_mo_by_feb": "2019-12-01T10:00:00.000", + "ECommerce.rollingCountByLeading": "8", + }, + Object { + "ECommerce.customOrderDateNoPreAgg": "2020-02-01T10:00:00.000", + "ECommerce.customOrderDateNoPreAgg.two_mo_by_feb": "2020-02-01T10:00:00.000", + "ECommerce.rollingCountByLeading": "12", + }, + Object { + "ECommerce.customOrderDateNoPreAgg": "2020-04-01T10:00:00.000", + "ECommerce.customOrderDateNoPreAgg.two_mo_by_feb": "2020-04-01T10:00:00.000", + "ECommerce.rollingCountByLeading": "6", + }, + Object { + "ECommerce.customOrderDateNoPreAgg": "2020-06-01T10:00:00.000", + "ECommerce.customOrderDateNoPreAgg.two_mo_by_feb": "2020-06-01T10:00:00.000", + "ECommerce.rollingCountByLeading": "19", + }, + Object { + "ECommerce.customOrderDateNoPreAgg": "2020-08-01T10:00:00.000", + "ECommerce.customOrderDateNoPreAgg.two_mo_by_feb": "2020-08-01T10:00:00.000", + "ECommerce.rollingCountByLeading": "16", + }, + Object { + "ECommerce.customOrderDateNoPreAgg": "2020-10-01T10:00:00.000", + "ECommerce.customOrderDateNoPreAgg.two_mo_by_feb": "2020-10-01T10:00:00.000", + "ECommerce.rollingCountByLeading": null, + }, + Object { + "ECommerce.customOrderDateNoPreAgg": "2020-12-01T10:00:00.000", + "ECommerce.customOrderDateNoPreAgg.two_mo_by_feb": "2020-12-01T10:00:00.000", + "ECommerce.rollingCountByLeading": null, + }, +] +`; + exports[`Queries with the @cubejs-backend/databricks-jdbc-driver querying custom granularities ECommerce: count by two_mo_by_feb + no dimension + rollingCountByTrailing 1`] = ` Array [ Object { From 733ad1fd0c6c31a32b698887c1261c29584c45b2 Mon Sep 17 00:00:00 2001 From: Konstantin Burkalev Date: Mon, 11 Aug 2025 23:06:36 +0300 Subject: [PATCH 11/11] add snapshot: SQL API: Extended nested Rollup over asterisk --- .../databricks-jdbc-full.test.ts.snap | 225 ++++++++++++++++++ 1 file changed, 225 insertions(+) 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 fbc612e51427d..768525e4489e2 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 @@ -1813,6 +1813,231 @@ Array [ ] `; +exports[`Queries with the @cubejs-backend/databricks-jdbc-driver SQL API: Extended nested Rollup over asterisk 1`] = ` +Array [ + Object { + "SUM(a.count)": "1", + "order": "CA-2017-100811", + "row": 4012, + }, + Object { + "SUM(a.count)": "1", + "order": "CA-2017-102379", + "row": 6272, + }, + Object { + "SUM(a.count)": "1", + "order": "CA-2017-102554", + "row": 3448, + }, + Object { + "SUM(a.count)": "1", + "order": "CA-2017-102925", + "row": 9473, + }, + Object { + "SUM(a.count)": "1", + "order": "CA-2017-105620", + "row": 8958, + }, + Object { + "SUM(a.count)": "1", + "order": "CA-2017-107503", + "row": 849, + }, + Object { + "SUM(a.count)": "1", + "order": "CA-2017-109183", + "row": 7293, + }, + Object { + "SUM(a.count)": "1", + "order": "CA-2017-112172", + "row": 7310, + }, + Object { + "SUM(a.count)": "1", + "order": "CA-2017-112515", + "row": 2655, + }, + Object { + "SUM(a.count)": "1", + "order": "CA-2017-115546", + "row": 4161, + }, + Object { + "SUM(a.count)": "1", + "order": "CA-2017-116127", + "row": 9584, + }, + Object { + "SUM(a.count)": "1", + "order": "CA-2017-118437", + "row": 1013, + }, + Object { + "SUM(a.count)": "1", + "order": "CA-2017-119284", + "row": 8697, + }, + Object { + "SUM(a.count)": "1", + "order": "CA-2017-120327", + "row": 4227, + }, + Object { + "SUM(a.count)": "1", + "order": "CA-2017-123001", + "row": 3934, + }, + Object { + "SUM(a.count)": "1", + "order": "CA-2017-123372", + "row": 2661, + }, + Object { + "SUM(a.count)": "1", + "order": "CA-2017-124296", + "row": 4031, + }, + Object { + "SUM(a.count)": "1", + "order": "CA-2017-126928", + "row": 8878, + }, + Object { + "SUM(a.count)": "1", + "order": "CA-2017-131492", + "row": 3060, + }, + Object { + "SUM(a.count)": "1", + "order": "CA-2017-131492", + "row": 3059, + }, + Object { + "SUM(a.count)": "1", + "order": "CA-2017-133648", + "row": 1995, + }, + Object { + "SUM(a.count)": "1", + "order": "CA-2017-134915", + "row": 2952, + }, + Object { + "SUM(a.count)": "1", + "order": "CA-2017-135069", + "row": 7425, + }, + Object { + "SUM(a.count)": "1", + "order": "CA-2017-138422", + "row": 2329, + }, + Object { + "SUM(a.count)": "1", + "order": "CA-2017-139661", + "row": 1494, + }, + Object { + "SUM(a.count)": "1", + "order": "CA-2017-140949", + "row": 2455, + }, + Object { + "SUM(a.count)": "1", + "order": "CA-2017-143567", + "row": 4882, + }, + Object { + "SUM(a.count)": "1", + "order": "CA-2017-144568", + "row": 3717, + }, + Object { + "SUM(a.count)": "1", + "order": "CA-2017-145142", + "row": 523, + }, + Object { + "SUM(a.count)": "1", + "order": "CA-2017-145653", + "row": 5220, + }, + Object { + "SUM(a.count)": "1", + "order": "CA-2017-145660", + "row": 6205, + }, + Object { + "SUM(a.count)": "1", + "order": "CA-2017-145772", + "row": 6125, + }, + Object { + "SUM(a.count)": "1", + "order": "CA-2017-147333", + "row": 5277, + }, + Object { + "SUM(a.count)": "1", + "order": "CA-2017-149048", + "row": 2595, + }, + Object { + "SUM(a.count)": "1", + "order": "CA-2017-150091", + "row": 8425, + }, + Object { + "SUM(a.count)": "1", + "order": "CA-2017-151799", + "row": 7698, + }, + Object { + "SUM(a.count)": "1", + "order": "CA-2017-160633", + "row": 9619, + }, + Object { + "SUM(a.count)": "1", + "order": "CA-2017-160633", + "row": 9618, + }, + Object { + "SUM(a.count)": "1", + "order": "CA-2017-163265", + "row": 8673, + }, + Object { + "SUM(a.count)": "1", + "order": "US-2017-119319", + "row": 8621, + }, + Object { + "SUM(a.count)": "1", + "order": "US-2017-124779", + "row": 6651, + }, + Object { + "SUM(a.count)": "1", + "order": "US-2017-132297", + "row": 3083, + }, + Object { + "SUM(a.count)": "1", + "order": "US-2017-133361", + "row": 6459, + }, + Object { + "SUM(a.count)": "1", + "order": "US-2017-141677", + "row": 7174, + }, +] +`; + exports[`Queries with the @cubejs-backend/databricks-jdbc-driver SQL API: NULLS FIRST/LAST SQL push down: nulls_first_last_sql_push_down 1`] = ` Array [ Object {