Skip to content

Commit

Permalink
fix: Rollups are sorted by name in rollups params of pre-aggregatio…
Browse files Browse the repository at this point in the history
…ns (#6011)
  • Loading branch information
paveltiunov authored Jan 16, 2023
1 parent 83906a7 commit 235ec70
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -445,7 +445,7 @@ export class CubeEvaluator extends CubeSymbols {
aggregation.measureReferences && this.evaluateReferences(cube, aggregation.measureReferences) || [],
timeDimensions,
rollups:
aggregation.rollupReferences && this.evaluateReferences(cube, aggregation.rollupReferences) || [],
aggregation.rollupReferences && this.evaluateReferences(cube, aggregation.rollupReferences, { originalSorting: true }) || [],
};
}
}
19 changes: 18 additions & 1 deletion packages/cubejs-testing/birdbox-fixtures/lambda/schema/Orders.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ cube(`Orders`, {

ordersByCompletedAtLambda: {
type: `rollupLambda`,
rollups: [ordersByCompletedAt, ordersByCompletedByDay],
rollups: [ordersByCompletedAt, ordersByCompletedByDay, AOrdersByCompletedByHour],
unionWithSourceData: true,
},

Expand Down Expand Up @@ -66,6 +66,23 @@ cube(`Orders`, {
buildRangeStart: {
sql: `SELECT DATE('2020-05-1')`,
},
buildRangeEnd: {
sql: `SELECT DATE('2020-05-5')`,
},
refreshKey: {
every: '1 day'
},
},

AOrdersByCompletedByHour: {
measures: [count],
dimensions: [status],
timeDimension: completedAt,
granularity: `day`,
partitionGranularity: `hour`,
buildRangeStart: {
sql: `SELECT DATE('2020-05-5')`,
},
buildRangeEnd: {
sql: `SELECT DATE('2020-05-7')`,
},
Expand Down
22 changes: 11 additions & 11 deletions packages/cubejs-testing/test/smoke-lambda.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,28 +32,27 @@ async function checkCubestoreState(cubestore: any) {
expect(rows.slice(0, 4)).toEqual([
{
table_schema: 'dev_pre_aggregations',
table_name: 'orders_orders_by_completed_at20200201',
build_range_end: '2020-02-29T23:59:59.999Z',
table_name: 'orders__a_orders_by_completed_by_hour2020050500',
build_range_end: '2020-05-05T00:59:59.999Z',
},
{
table_schema: 'dev_pre_aggregations',
table_name: 'orders_orders_by_completed_at20200301',
build_range_end: '2020-03-31T23:59:59.999Z',
table_name: 'orders__a_orders_by_completed_by_hour2020050501',
build_range_end: '2020-05-05T01:59:59.999Z',
},
{
table_schema: 'dev_pre_aggregations',
table_name: 'orders_orders_by_completed_at20200401',
build_range_end: '2020-04-30T23:59:59.999Z',
table_name: 'orders__a_orders_by_completed_by_hour2020050502',
build_range_end: '2020-05-05T02:59:59.999Z',
},
{
table_schema: 'dev_pre_aggregations',
table_name: 'orders_orders_by_completed_at20200501',
build_range_end: '2020-05-01T00:00:00.000Z',
table_name: 'orders__a_orders_by_completed_by_hour2020050503',
build_range_end: '2020-05-05T03:59:59.999Z',
},
]);
expect(table.build_range_end).toEqual('2020-05-01T00:00:00.000Z');
rows = await cubestore.query(`SELECT * FROM ${table.table_schema}.${table.table_name}`, []);
expect(rows.length).toEqual(0);
expect(rows.length).toEqual(1);
}

describe('lambda', () => {
Expand Down Expand Up @@ -140,7 +139,8 @@ describe('lambda', () => {
// @ts-ignore
expect(Object.keys(response.loadResponse.results[0].usedPreAggregations)).toEqual([
'dev_pre_aggregations.orders_orders_by_completed_at',
'dev_pre_aggregations.orders_orders_by_completed_by_day'
'dev_pre_aggregations.orders_orders_by_completed_by_day',
'dev_pre_aggregations.orders__a_orders_by_completed_by_hour'
]);

// With lambda-view we observe all 'fresh' data, with no partition/buildRange limit.
Expand Down

0 comments on commit 235ec70

Please sign in to comment.