From 5034e2125a33408bca7e58e995d49622d747c180 Mon Sep 17 00:00:00 2001 From: Alexandr Romanenko Date: Tue, 4 Mar 2025 17:32:29 +0100 Subject: [PATCH 1/2] fix(tesseract): fix wrong default alias for symbols with digits in name --- .../postgres/sql-generation.test.ts | 23 +++++++++++++++++++ .../src/planner/sql_templates/plan.rs | 2 +- 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/packages/cubejs-schema-compiler/test/integration/postgres/sql-generation.test.ts b/packages/cubejs-schema-compiler/test/integration/postgres/sql-generation.test.ts index e11b7f01b3af3..520fd6e856313 100644 --- a/packages/cubejs-schema-compiler/test/integration/postgres/sql-generation.test.ts +++ b/packages/cubejs-schema-compiler/test/integration/postgres/sql-generation.test.ts @@ -45,6 +45,10 @@ describe('SQL Generation', () => { type: 'sum', sql: 'amount', }, + revenue_1d_d1_dd: { + type: 'sum', + sql: 'amount', + }, visitor_revenue: { type: 'sum', sql: 'amount', @@ -3265,6 +3269,25 @@ SELECT 1 AS revenue, cast('2024-01-01' AS timestamp) as time UNION ALL }] )); + it('aliases for columns with digits and underscores', async () => runQueryTest( + { + measures: ['visitors.revenue_1d_d1_dd'], + }, + [{ + visitors__revenue_1d_d1_dd: '2000', + }] + )); + + it('multiplied sum no dimensions through view', async () => runQueryTest( + { + measures: ['visitors_visitors_checkins_view.revenue', 'visitors_visitors_checkins_view.id_sum'], + }, + [{ + visitors_visitors_checkins_view__revenue: '2000', + visitors_visitors_checkins_view__id_sum: '21' + }] + )); + // Subquery aggregation for multiplied measure (and any `keysSelect` for that matter) // should pick up all dimensions, even through member expressions it('multiplied sum with dimension member expressions', async () => runQueryTest( diff --git a/rust/cubesqlplanner/cubesqlplanner/src/planner/sql_templates/plan.rs b/rust/cubesqlplanner/cubesqlplanner/src/planner/sql_templates/plan.rs index edd4e4d927b16..7ef0e6e1f6001 100644 --- a/rust/cubesqlplanner/cubesqlplanner/src/planner/sql_templates/plan.rs +++ b/rust/cubesqlplanner/cubesqlplanner/src/planner/sql_templates/plan.rs @@ -33,7 +33,7 @@ impl PlanSqlTemplates { .with_boundaries(&[ UNDERSCORE_UPPER_BOUND, Boundary::LOWER_UPPER, - Boundary::DIGIT_LOWER, + Boundary::DIGIT_UPPER, Boundary::ACRONYM, ]) .to_case(Case::Snake) From 524bffc8dda9521fe4fc592b0fb5af1def273281 Mon Sep 17 00:00:00 2001 From: Alexandr Romanenko Date: Tue, 4 Mar 2025 19:22:47 +0100 Subject: [PATCH 2/2] fix --- .../test/integration/postgres/sql-generation.test.ts | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/packages/cubejs-schema-compiler/test/integration/postgres/sql-generation.test.ts b/packages/cubejs-schema-compiler/test/integration/postgres/sql-generation.test.ts index 520fd6e856313..cf6312b48c188 100644 --- a/packages/cubejs-schema-compiler/test/integration/postgres/sql-generation.test.ts +++ b/packages/cubejs-schema-compiler/test/integration/postgres/sql-generation.test.ts @@ -3278,16 +3278,6 @@ SELECT 1 AS revenue, cast('2024-01-01' AS timestamp) as time UNION ALL }] )); - it('multiplied sum no dimensions through view', async () => runQueryTest( - { - measures: ['visitors_visitors_checkins_view.revenue', 'visitors_visitors_checkins_view.id_sum'], - }, - [{ - visitors_visitors_checkins_view__revenue: '2000', - visitors_visitors_checkins_view__id_sum: '21' - }] - )); - // Subquery aggregation for multiplied measure (and any `keysSelect` for that matter) // should pick up all dimensions, even through member expressions it('multiplied sum with dimension member expressions', async () => runQueryTest(