Skip to content

Commit 3020a96

Browse files
committed
remove runningTotal related code
1 parent ce7e593 commit 3020a96

File tree

7 files changed

+4
-280
lines changed

7 files changed

+4
-280
lines changed

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

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -126,13 +126,10 @@ export class BaseMeasure {
126126
}
127127

128128
public static isCumulative(definition) {
129-
return definition.type === 'runningTotal' || !!definition.rollingWindow;
129+
return !!definition.rollingWindow;
130130
}
131131

132132
public rollingWindowDefinition() {
133-
if (this.measureDefinition().type === 'runningTotal') {
134-
throw new UserError('runningTotal rollups aren\'t supported. Please consider replacing runningTotal measure with rollingWindow.');
135-
}
136133
const { type } = this.measureDefinition().rollingWindow;
137134
if (type && type !== 'fixed') {
138135
throw new UserError(`Only fixed rolling windows are supported by Cube Store but got '${type}' rolling window`);
@@ -142,9 +139,6 @@ export class BaseMeasure {
142139

143140
public dateJoinCondition() {
144141
const definition = this.measureDefinition();
145-
if (definition.type === 'runningTotal') {
146-
return this.query.runningTotalDateJoinCondition();
147-
}
148142
const { rollingWindow } = definition;
149143
if (rollingWindow.type === 'to_date') {
150144
return this.query.rollingWindowToDateJoinCondition(rollingWindow.granularity);

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

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -731,16 +731,6 @@ export class BaseQuery {
731731
});
732732
}
733733

734-
runningTotalDateJoinCondition() {
735-
return this.timeDimensions.map(
736-
d => [
737-
d,
738-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
739-
(dateFrom, dateTo, dateField, dimensionDateFrom, dimensionDateTo) => `${dateField} >= ${dimensionDateFrom} AND ${dateField} <= ${dateTo}`
740-
]
741-
);
742-
}
743-
744734
rollingWindowToDateJoinCondition(granularity) {
745735
return this.timeDimensions.map(
746736
d => [
@@ -2675,8 +2665,6 @@ export class BaseQuery {
26752665
this.countDistinctApprox(evaluateSql);
26762666
} else if (symbol.type === 'countDistinct' || symbol.type === 'count' && !symbol.sql && multiplied) {
26772667
return `count(distinct ${evaluateSql})`;
2678-
} else if (symbol.type === 'runningTotal') {
2679-
return `sum(${evaluateSql})`; // TODO
26802668
}
26812669
if (multiplied) {
26822670
if (symbol.type === 'number' && evaluateSql === 'count(*)') {

packages/cubejs-schema-compiler/src/compiler/CubeValidator.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -549,15 +549,15 @@ const CubeRefreshKeySchema = condition(
549549
);
550550

551551
const measureType = Joi.string().valid(
552-
'number', 'string', 'boolean', 'time', 'sum', 'avg', 'min', 'max', 'countDistinct', 'runningTotal', 'countDistinctApprox'
552+
'number', 'string', 'boolean', 'time', 'sum', 'avg', 'min', 'max', 'countDistinct', 'countDistinctApprox'
553553
);
554554

555555
const measureTypeWithCount = Joi.string().valid(
556-
'count', 'number', 'string', 'boolean', 'time', 'sum', 'avg', 'min', 'max', 'countDistinct', 'runningTotal', 'countDistinctApprox'
556+
'count', 'number', 'string', 'boolean', 'time', 'sum', 'avg', 'min', 'max', 'countDistinct', 'countDistinctApprox'
557557
);
558558

559559
const multiStageMeasureType = Joi.string().valid(
560-
'count', 'number', 'string', 'boolean', 'time', 'sum', 'avg', 'min', 'max', 'countDistinct', 'runningTotal', 'countDistinctApprox',
560+
'count', 'number', 'string', 'boolean', 'time', 'sum', 'avg', 'min', 'max', 'countDistinct', 'countDistinctApprox',
561561
'rank'
562562
);
563563

packages/cubejs-schema-compiler/test/integration/clickhouse/clickhouse-graph-builder.test.ts

Lines changed: 0 additions & 119 deletions
Original file line numberDiff line numberDiff line change
@@ -50,10 +50,6 @@ describe('ClickHouse JoinGraph', () => {
5050
}]
5151
},
5252
per_visitor_revenue: perVisitorRevenueMeasure,
53-
revenueRunning: {
54-
type: 'runningTotal',
55-
sql: 'amount'
56-
},
5753
revenueRolling: {
5854
type: 'sum',
5955
sql: 'amount',
@@ -85,14 +81,6 @@ describe('ClickHouse JoinGraph', () => {
8581
offset: 'start'
8682
}
8783
},
88-
runningCount: {
89-
type: 'runningTotal',
90-
sql: '1'
91-
},
92-
runningRevenuePerCount: {
93-
type: 'number',
94-
sql: \`round(\${revenueRunning} / \${runningCount})\`
95-
},
9684
averageCheckins: {
9785
type: 'avg',
9886
sql: \`\${doubledCheckings}\`
@@ -385,68 +373,6 @@ describe('ClickHouse JoinGraph', () => {
385373
visitors__per_visitor_revenue: '60'
386374
}]));
387375

388-
// FAILS - need to finish query to override ::timestamptz
389-
it.skip('running total', () => {
390-
const result = compiler.compile().then(() => {
391-
const query = new ClickHouseQuery({ joinGraph, cubeEvaluator, compiler }, {
392-
measures: [
393-
'visitors.revenueRunning'
394-
],
395-
timeDimensions: [{
396-
dimension: 'visitors.created_at',
397-
granularity: 'day',
398-
dateRange: ['2017-01-01', '2017-01-10']
399-
}],
400-
order: [{
401-
id: 'visitors.created_at'
402-
}],
403-
timezone: 'America/Los_Angeles'
404-
});
405-
406-
logSqlAndParams(query);
407-
408-
// TODO ordering doesn't work for running total
409-
return dbRunner.testQuery(query.buildSqlAndParams()).then(res => {
410-
debugLog(JSON.stringify(res));
411-
expect(res).toEqual(
412-
[{
413-
visitors__created_at_day: '2017-01-01T00:00:00.000Z',
414-
visitors__revenue_running: null
415-
}, {
416-
visitors__created_at_day: '2017-01-02T00:00:00.000Z',
417-
visitors__revenue_running: '100'
418-
}, {
419-
visitors__created_at_day: '2017-01-03T00:00:00.000Z',
420-
visitors__revenue_running: '100'
421-
}, {
422-
visitors__created_at_day: '2017-01-04T00:00:00.000Z',
423-
visitors__revenue_running: '300'
424-
}, {
425-
visitors__created_at_day: '2017-01-05T00:00:00.000Z',
426-
visitors__revenue_running: '600'
427-
}, {
428-
visitors__created_at_day: '2017-01-06T00:00:00.000Z',
429-
visitors__revenue_running: '1500'
430-
}, {
431-
visitors__created_at_day: '2017-01-07T00:00:00.000Z',
432-
visitors__revenue_running: '1500'
433-
}, {
434-
visitors__created_at_day: '2017-01-08T00:00:00.000Z',
435-
visitors__revenue_running: '1500'
436-
}, {
437-
visitors__created_at_day: '2017-01-09T00:00:00.000Z',
438-
visitors__revenue_running: '1500'
439-
}, {
440-
visitors__created_at_day: '2017-01-10T00:00:00.000Z',
441-
visitors__revenue_running: '1500'
442-
}]
443-
);
444-
});
445-
});
446-
447-
return result;
448-
});
449-
450376
// FAILS - need to finish query to override ::timestamptz
451377
it.skip('rolling', () => runQueryTest({
452378
measures: [
@@ -577,51 +503,6 @@ describe('ClickHouse JoinGraph', () => {
577503
{ visitors__created_at_sql_utils_day: '2017-01-06T00:00:00.000', visitors__visitor_count: '2' }
578504
]));
579505

580-
it('running total total', () => runQueryTest({
581-
measures: [
582-
'visitors.revenueRunning'
583-
],
584-
timeDimensions: [{
585-
dimension: 'visitors.created_at',
586-
dateRange: ['2017-01-01', '2017-01-10']
587-
}],
588-
order: [{
589-
id: 'visitors.created_at'
590-
}],
591-
timezone: 'America/Los_Angeles'
592-
}, [
593-
{
594-
visitors__revenue_running: '1500'
595-
}
596-
]));
597-
598-
// FAILS Unmatched parentheses
599-
it.skip('running total ratio', () => runQueryTest({
600-
measures: [
601-
'visitors.runningRevenuePerCount'
602-
],
603-
timeDimensions: [{
604-
dimension: 'visitors.created_at',
605-
granularity: 'day',
606-
dateRange: ['2017-01-01', '2017-01-10']
607-
}],
608-
order: [{
609-
id: 'visitors.created_at'
610-
}],
611-
timezone: 'America/Los_Angeles'
612-
}, [
613-
{ visitors__created_at_day: '2017-01-01T00:00:00.000Z', visitors__running_revenue_per_count: null },
614-
{ visitors__created_at_day: '2017-01-02T00:00:00.000Z', visitors__running_revenue_per_count: '100' },
615-
{ visitors__created_at_day: '2017-01-03T00:00:00.000Z', visitors__running_revenue_per_count: '100' },
616-
{ visitors__created_at_day: '2017-01-04T00:00:00.000Z', visitors__running_revenue_per_count: '150' },
617-
{ visitors__created_at_day: '2017-01-05T00:00:00.000Z', visitors__running_revenue_per_count: '200' },
618-
{ visitors__created_at_day: '2017-01-06T00:00:00.000Z', visitors__running_revenue_per_count: '300' },
619-
{ visitors__created_at_day: '2017-01-07T00:00:00.000Z', visitors__running_revenue_per_count: '300' },
620-
{ visitors__created_at_day: '2017-01-08T00:00:00.000Z', visitors__running_revenue_per_count: '300' },
621-
{ visitors__created_at_day: '2017-01-09T00:00:00.000Z', visitors__running_revenue_per_count: '300' },
622-
{ visitors__created_at_day: '2017-01-10T00:00:00.000Z', visitors__running_revenue_per_count: '300' }
623-
]));
624-
625506
// FAILS ClickHouse supports multiple approximate aggregators:
626507
// uniq, uniqCombined, uniqHLL12, need to pick one to use and implement it in query
627508
it.skip('hll rolling', () => {

packages/cubejs-schema-compiler/test/integration/mssql/mssql-ungrouped.test.ts

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -50,10 +50,6 @@ describe('MSSqlUngrouped', () => {
5050
}]
5151
},
5252
per_visitor_revenue: perVisitorRevenueMeasure,
53-
revenueRunning: {
54-
type: 'runningTotal',
55-
sql: 'amount'
56-
},
5753
revenueRolling: {
5854
type: 'sum',
5955
sql: 'amount',
@@ -85,14 +81,6 @@ describe('MSSqlUngrouped', () => {
8581
offset: 'start'
8682
}
8783
},
88-
runningCount: {
89-
type: 'runningTotal',
90-
sql: '1'
91-
},
92-
runningRevenuePerCount: {
93-
type: 'number',
94-
sql: \`round(\${revenueRunning} / \${runningCount})\`
95-
},
9684
averageCheckins: {
9785
type: 'avg',
9886
sql: \`\${doubledCheckings}\`

packages/cubejs-schema-compiler/test/integration/postgres/sql-generation-logic.test.ts

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -45,10 +45,6 @@ describe('SQL Generation', () => {
4545
}]
4646
},
4747
per_visitor_revenue: perVisitorRevenueMeasure,
48-
revenueRunning: {
49-
type: 'runningTotal',
50-
sql: 'amount'
51-
},
5248
revenueRolling: {
5349
type: 'sum',
5450
sql: 'amount',
@@ -80,14 +76,6 @@ describe('SQL Generation', () => {
8076
offset: 'start'
8177
}
8278
},
83-
runningCount: {
84-
type: 'runningTotal',
85-
sql: '1'
86-
},
87-
runningRevenuePerCount: {
88-
type: 'number',
89-
sql: \`round(\${revenueRunning} / \${runningCount})\`
90-
},
9179
averageCheckins: {
9280
type: 'avg',
9381
sql: \`\${doubledCheckings}\`

0 commit comments

Comments
 (0)