Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions DEPRECATION.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ features:
| Removed | [Node.js 14](#nodejs-14) | v0.32.0 | v0.35.0 |
| Removed | [Using Redis for in-memory cache and queue](#using-redis-for-in-memory-cache-and-queue) | v0.32.0 | v0.36.0 |
| Deprecated | [`SECURITY_CONTEXT`](#security_context) | v0.33.0 | |
| Deprecated | [`running_total` measure type](#running_total-measure-type) | v0.33.39 | |
| Removed | [`running_total` measure type](#running_total-measure-type) | v0.33.39 | v1.2.0 |
| Deprecated | [Top-level `includes` parameter in views](#top-level-includes-parameter-in-views) | v0.34.34 | |
| Removed | [Node.js 16](#nodejs-16) | v0.35.0 | v0.36.0 |
| Removed | [MySQL-based SQL API](#mysql-based-sql-api) | v0.35.0 | v0.35.0 |
Expand Down Expand Up @@ -341,11 +341,11 @@ instead.

### `running_total` measure type

**Deprecated in Release: v0.33.39**
**Removed in release: v1.2.0**

The `running_total` measure type is now deprecated, and we recommend using
The `running_total` measure type has been removed. Instead, we recommend using the
[`rolling_window`](https://cube.dev/docs/product/data-modeling/reference/measures#rolling_window)
to calculate running totals instead.
parameter to calculate running totals.

### Top-level `includes` parameter in views

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,13 +126,10 @@ export class BaseMeasure {
}

public static isCumulative(definition) {
return definition.type === 'runningTotal' || !!definition.rollingWindow;
return !!definition.rollingWindow;
}

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

public dateJoinCondition() {
const definition = this.measureDefinition();
if (definition.type === 'runningTotal') {
return this.query.runningTotalDateJoinCondition();
}
const { rollingWindow } = definition;
if (rollingWindow.type === 'to_date') {
return this.query.rollingWindowToDateJoinCondition(rollingWindow.granularity);
Expand Down
12 changes: 0 additions & 12 deletions packages/cubejs-schema-compiler/src/adapter/BaseQuery.js
Original file line number Diff line number Diff line change
Expand Up @@ -731,16 +731,6 @@ export class BaseQuery {
});
}

runningTotalDateJoinCondition() {
return this.timeDimensions.map(
d => [
d,
// eslint-disable-next-line @typescript-eslint/no-unused-vars
(dateFrom, dateTo, dateField, dimensionDateFrom, dimensionDateTo) => `${dateField} >= ${dimensionDateFrom} AND ${dateField} <= ${dateTo}`
]
);
}

rollingWindowToDateJoinCondition(granularity) {
return this.timeDimensions.map(
d => [
Expand Down Expand Up @@ -2675,8 +2665,6 @@ export class BaseQuery {
this.countDistinctApprox(evaluateSql);
} else if (symbol.type === 'countDistinct' || symbol.type === 'count' && !symbol.sql && multiplied) {
return `count(distinct ${evaluateSql})`;
} else if (symbol.type === 'runningTotal') {
return `sum(${evaluateSql})`; // TODO
}
if (multiplied) {
if (symbol.type === 'number' && evaluateSql === 'count(*)') {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -549,15 +549,15 @@ const CubeRefreshKeySchema = condition(
);

const measureType = Joi.string().valid(
'number', 'string', 'boolean', 'time', 'sum', 'avg', 'min', 'max', 'countDistinct', 'runningTotal', 'countDistinctApprox'
'number', 'string', 'boolean', 'time', 'sum', 'avg', 'min', 'max', 'countDistinct', 'countDistinctApprox'
);

const measureTypeWithCount = Joi.string().valid(
'count', 'number', 'string', 'boolean', 'time', 'sum', 'avg', 'min', 'max', 'countDistinct', 'runningTotal', 'countDistinctApprox'
'count', 'number', 'string', 'boolean', 'time', 'sum', 'avg', 'min', 'max', 'countDistinct', 'countDistinctApprox'
);

const multiStageMeasureType = Joi.string().valid(
'count', 'number', 'string', 'boolean', 'time', 'sum', 'avg', 'min', 'max', 'countDistinct', 'runningTotal', 'countDistinctApprox',
'count', 'number', 'string', 'boolean', 'time', 'sum', 'avg', 'min', 'max', 'countDistinct', 'countDistinctApprox',
'rank'
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,6 @@ describe('ClickHouse JoinGraph', () => {
}]
},
per_visitor_revenue: perVisitorRevenueMeasure,
revenueRunning: {
type: 'runningTotal',
sql: 'amount'
},
revenueRolling: {
type: 'sum',
sql: 'amount',
Expand Down Expand Up @@ -85,14 +81,6 @@ describe('ClickHouse JoinGraph', () => {
offset: 'start'
}
},
runningCount: {
type: 'runningTotal',
sql: '1'
},
runningRevenuePerCount: {
type: 'number',
sql: \`round(\${revenueRunning} / \${runningCount})\`
},
averageCheckins: {
type: 'avg',
sql: \`\${doubledCheckings}\`
Expand Down Expand Up @@ -385,68 +373,6 @@ describe('ClickHouse JoinGraph', () => {
visitors__per_visitor_revenue: '60'
}]));

// FAILS - need to finish query to override ::timestamptz
it.skip('running total', () => {
const result = compiler.compile().then(() => {
const query = new ClickHouseQuery({ joinGraph, cubeEvaluator, compiler }, {
measures: [
'visitors.revenueRunning'
],
timeDimensions: [{
dimension: 'visitors.created_at',
granularity: 'day',
dateRange: ['2017-01-01', '2017-01-10']
}],
order: [{
id: 'visitors.created_at'
}],
timezone: 'America/Los_Angeles'
});

logSqlAndParams(query);

// TODO ordering doesn't work for running total
return dbRunner.testQuery(query.buildSqlAndParams()).then(res => {
debugLog(JSON.stringify(res));
expect(res).toEqual(
[{
visitors__created_at_day: '2017-01-01T00:00:00.000Z',
visitors__revenue_running: null
}, {
visitors__created_at_day: '2017-01-02T00:00:00.000Z',
visitors__revenue_running: '100'
}, {
visitors__created_at_day: '2017-01-03T00:00:00.000Z',
visitors__revenue_running: '100'
}, {
visitors__created_at_day: '2017-01-04T00:00:00.000Z',
visitors__revenue_running: '300'
}, {
visitors__created_at_day: '2017-01-05T00:00:00.000Z',
visitors__revenue_running: '600'
}, {
visitors__created_at_day: '2017-01-06T00:00:00.000Z',
visitors__revenue_running: '1500'
}, {
visitors__created_at_day: '2017-01-07T00:00:00.000Z',
visitors__revenue_running: '1500'
}, {
visitors__created_at_day: '2017-01-08T00:00:00.000Z',
visitors__revenue_running: '1500'
}, {
visitors__created_at_day: '2017-01-09T00:00:00.000Z',
visitors__revenue_running: '1500'
}, {
visitors__created_at_day: '2017-01-10T00:00:00.000Z',
visitors__revenue_running: '1500'
}]
);
});
});

return result;
});

// FAILS - need to finish query to override ::timestamptz
it.skip('rolling', () => runQueryTest({
measures: [
Expand Down Expand Up @@ -577,51 +503,6 @@ describe('ClickHouse JoinGraph', () => {
{ visitors__created_at_sql_utils_day: '2017-01-06T00:00:00.000', visitors__visitor_count: '2' }
]));

it('running total total', () => runQueryTest({
measures: [
'visitors.revenueRunning'
],
timeDimensions: [{
dimension: 'visitors.created_at',
dateRange: ['2017-01-01', '2017-01-10']
}],
order: [{
id: 'visitors.created_at'
}],
timezone: 'America/Los_Angeles'
}, [
{
visitors__revenue_running: '1500'
}
]));

// FAILS Unmatched parentheses
it.skip('running total ratio', () => runQueryTest({
measures: [
'visitors.runningRevenuePerCount'
],
timeDimensions: [{
dimension: 'visitors.created_at',
granularity: 'day',
dateRange: ['2017-01-01', '2017-01-10']
}],
order: [{
id: 'visitors.created_at'
}],
timezone: 'America/Los_Angeles'
}, [
{ visitors__created_at_day: '2017-01-01T00:00:00.000Z', visitors__running_revenue_per_count: null },
{ visitors__created_at_day: '2017-01-02T00:00:00.000Z', visitors__running_revenue_per_count: '100' },
{ visitors__created_at_day: '2017-01-03T00:00:00.000Z', visitors__running_revenue_per_count: '100' },
{ visitors__created_at_day: '2017-01-04T00:00:00.000Z', visitors__running_revenue_per_count: '150' },
{ visitors__created_at_day: '2017-01-05T00:00:00.000Z', visitors__running_revenue_per_count: '200' },
{ visitors__created_at_day: '2017-01-06T00:00:00.000Z', visitors__running_revenue_per_count: '300' },
{ visitors__created_at_day: '2017-01-07T00:00:00.000Z', visitors__running_revenue_per_count: '300' },
{ visitors__created_at_day: '2017-01-08T00:00:00.000Z', visitors__running_revenue_per_count: '300' },
{ visitors__created_at_day: '2017-01-09T00:00:00.000Z', visitors__running_revenue_per_count: '300' },
{ visitors__created_at_day: '2017-01-10T00:00:00.000Z', visitors__running_revenue_per_count: '300' }
]));

// FAILS ClickHouse supports multiple approximate aggregators:
// uniq, uniqCombined, uniqHLL12, need to pick one to use and implement it in query
it.skip('hll rolling', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,6 @@ describe('MSSqlUngrouped', () => {
}]
},
per_visitor_revenue: perVisitorRevenueMeasure,
revenueRunning: {
type: 'runningTotal',
sql: 'amount'
},
revenueRolling: {
type: 'sum',
sql: 'amount',
Expand Down Expand Up @@ -85,14 +81,6 @@ describe('MSSqlUngrouped', () => {
offset: 'start'
}
},
runningCount: {
type: 'runningTotal',
sql: '1'
},
runningRevenuePerCount: {
type: 'number',
sql: \`round(\${revenueRunning} / \${runningCount})\`
},
averageCheckins: {
type: 'avg',
sql: \`\${doubledCheckings}\`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,6 @@ describe('SQL Generation', () => {
}]
},
per_visitor_revenue: perVisitorRevenueMeasure,
revenueRunning: {
type: 'runningTotal',
sql: 'amount'
},
revenueRolling: {
type: 'sum',
sql: 'amount',
Expand Down Expand Up @@ -80,14 +76,6 @@ describe('SQL Generation', () => {
offset: 'start'
}
},
runningCount: {
type: 'runningTotal',
sql: '1'
},
runningRevenuePerCount: {
type: 'number',
sql: \`round(\${revenueRunning} / \${runningCount})\`
},
averageCheckins: {
type: 'avg',
sql: \`\${doubledCheckings}\`
Expand Down
Loading
Loading