Skip to content

Commit da4d7aa

Browse files
authored
feat(tesseract): Full key aggregate and logical plan refactoring (#9807)
1 parent d1d8160 commit da4d7aa

File tree

118 files changed

+5634
-3574
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

118 files changed

+5634
-3574
lines changed

packages/cubejs-schema-compiler/src/adapter/BaseQuery.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4116,7 +4116,7 @@ export class BaseQuery {
41164116
VAR_SAMP: 'VAR_SAMP({{ args_concat }})',
41174117
COVAR_POP: 'COVAR_POP({{ args_concat }})',
41184118
COVAR_SAMP: 'COVAR_SAMP({{ args_concat }})',
4119-
4119+
GROUP_ANY: 'max({{ expr }})',
41204120
COALESCE: 'COALESCE({{ args_concat }})',
41214121
CONCAT: 'CONCAT({{ args_concat }})',
41224122
FLOOR: 'FLOOR({{ args_concat }})',

packages/cubejs-schema-compiler/src/adapter/PrestodbQuery.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ export class PrestodbQuery extends BaseQuery {
142142
templates.statements.select = '{% if ctes %} WITH \n' +
143143
'{{ ctes | join(\',\n\') }}\n' +
144144
'{% endif %}' +
145-
'SELECT {{ select_concat | map(attribute=\'aliased\') | join(\', \') }} {% if from %}\n' +
145+
'SELECT {% if distinct %}DISTINCT {% endif %}{{ select_concat | map(attribute=\'aliased\') | join(\', \') }} {% if from %}\n' +
146146
'FROM (\n {{ from }}\n) AS {{ from_alias }} {% elif from_prepared %}\n' +
147147
'FROM {{ from_prepared }}' +
148148
'{% endif %}' +

packages/cubejs-schema-compiler/test/integration/postgres/calendars.test.ts

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -697,6 +697,11 @@ cubes:
697697
calendar_orders__count_shifted_calendar_m: '3',
698698
custom_calendar__retail_date_month: '2025-12-01T00:00:00.000Z',
699699
},
700+
{
701+
calendar_orders__count: null,
702+
calendar_orders__count_shifted_calendar_m: '3',
703+
custom_calendar__retail_date_month: '2026-01-01T00:00:00.000Z',
704+
},
700705
]));
701706

702707
it('Count shifted by retail week (common shift + custom granularity)', async () => runQueryTest({
@@ -708,6 +713,11 @@ cubes:
708713
}],
709714
order: [{ id: 'custom_calendar.retail_date' }]
710715
}, [
716+
{
717+
calendar_orders__count: '1',
718+
calendar_orders__count_shifted_calendar_w: null,
719+
custom_calendar__retail_date_week: '2025-02-02T00:00:00.000Z',
720+
},
711721
{
712722
calendar_orders__count: '1',
713723
calendar_orders__count_shifted_calendar_w: '1',
@@ -723,11 +733,31 @@ cubes:
723733
calendar_orders__count_shifted_calendar_w: '1',
724734
custom_calendar__retail_date_week: '2025-02-23T00:00:00.000Z',
725735
},
736+
{
737+
calendar_orders__count: null,
738+
calendar_orders__count_shifted_calendar_w: '1',
739+
custom_calendar__retail_date_week: '2025-03-02T00:00:00.000Z',
740+
},
741+
{
742+
calendar_orders__count: '1',
743+
calendar_orders__count_shifted_calendar_w: null,
744+
custom_calendar__retail_date_week: '2025-03-09T00:00:00.000Z',
745+
},
726746
{
727747
calendar_orders__count: '1',
728748
calendar_orders__count_shifted_calendar_w: '1',
729749
custom_calendar__retail_date_week: '2025-03-16T00:00:00.000Z',
730750
},
751+
{
752+
calendar_orders__count: null,
753+
calendar_orders__count_shifted_calendar_w: '1',
754+
custom_calendar__retail_date_week: '2025-03-23T00:00:00.000Z',
755+
},
756+
{
757+
calendar_orders__count: '1',
758+
calendar_orders__count_shifted_calendar_w: null,
759+
custom_calendar__retail_date_week: '2025-03-30T00:00:00.000Z',
760+
},
731761
{
732762
calendar_orders__count: '1',
733763
calendar_orders__count_shifted_calendar_w: '1',

packages/cubejs-schema-compiler/test/integration/postgres/multi-stage.test.ts

Lines changed: 33 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -198,24 +198,39 @@ views:
198198
}
199199
],
200200
timezone: 'UTC'
201-
}, [{
202-
orders__date_year: '2023-01-01T00:00:00.000Z',
203-
orders__revenue: '15',
204-
orders__revenue_1_y_ago: '5',
205-
orders__cagr_1_y: '2.0000000000000000'
206-
},
207-
{
208-
orders__date_year: '2024-01-01T00:00:00.000Z',
209-
orders__revenue: '30',
210-
orders__revenue_1_y_ago: '15',
211-
orders__cagr_1_y: '1.0000000000000000'
212-
},
213-
{
214-
orders__date_year: '2025-01-01T00:00:00.000Z',
215-
orders__revenue: '5',
216-
orders__revenue_1_y_ago: '30',
217-
orders__cagr_1_y: '-0.83333333333333333333'
218-
}],
201+
}, [
202+
{
203+
orders__cagr_1_y: null,
204+
orders__date_year: '2022-01-01T00:00:00.000Z',
205+
orders__revenue: '5',
206+
orders__revenue_1_y_ago: null,
207+
},
208+
{
209+
orders__date_year: '2023-01-01T00:00:00.000Z',
210+
orders__revenue: '15',
211+
orders__revenue_1_y_ago: '5',
212+
orders__cagr_1_y: '2.0000000000000000'
213+
},
214+
{
215+
orders__date_year: '2024-01-01T00:00:00.000Z',
216+
orders__revenue: '30',
217+
orders__revenue_1_y_ago: '15',
218+
orders__cagr_1_y: '1.0000000000000000'
219+
},
220+
{
221+
orders__date_year: '2025-01-01T00:00:00.000Z',
222+
orders__revenue: '5',
223+
orders__revenue_1_y_ago: '30',
224+
orders__cagr_1_y: '-0.83333333333333333333'
225+
},
226+
227+
{
228+
orders__cagr_1_y: null,
229+
orders__date_year: '2026-01-01T00:00:00.000Z',
230+
orders__revenue: null,
231+
orders__revenue_1_y_ago: '5',
232+
},
233+
],
219234
{ joinGraph, cubeEvaluator, compiler }));
220235
} else {
221236
// This test is working only in tesseract

0 commit comments

Comments
 (0)