Skip to content

Commit

Permalink
fix(client-core): nullish measure values (#3664)
Browse files Browse the repository at this point in the history
BREAKING CHANGE: All undefined/null measure values will now be converted to 0
  • Loading branch information
vasilev-alex authored Dec 14, 2021
1 parent c9249a5 commit f28f803
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
4 changes: 1 addition & 3 deletions packages/cubejs-client-core/src/ResultSet.js
Original file line number Diff line number Diff line change
Expand Up @@ -355,7 +355,7 @@ class ResultSet {
const pivotImpl = (resultIndex = 0) => {
let groupByXAxis = groupByToPairs(({ xValues }) => this.axisValuesString(xValues));

let measureValue = (row, measure) => row[measure];
const measureValue = (row, measure) => row[measure] || 0;

if (
pivotConfig.fillMissingDates &&
Expand All @@ -379,8 +379,6 @@ class ResultSet {
);
return series[resultIndex].map(d => [d, byXValues[d] || [{ xValues: [d], row: {} }]]);
};

measureValue = (row, measure) => row[measure] || 0;
}
}

Expand Down
5 changes: 2 additions & 3 deletions packages/cubejs-client-core/src/tests/ResultSet.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ describe('ResultSet', () => {
{
x: 'Name 1',

'Foo.count': null,
'Foo.count': 0,
xValues: [
'Name 1'
],
Expand Down Expand Up @@ -235,8 +235,7 @@ describe('ResultSet', () => {
expect(resultSet.chartPivot()).toEqual([
{
x: 'Name 1',

'Foo.count': undefined,
'Foo.count': 0,
xValues: [
'Name 1'
],
Expand Down
3 changes: 3 additions & 0 deletions packages/cubejs-client-core/src/tests/data-blending.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -255,11 +255,14 @@ describe('data blending', () => {
xValues: ['2020-08-01T00:00:00.000'],
'Orders.count': 1,
'Australia,Users.count': 20,
'Italy,Users.count': 0,
'Spain,Users.count': 0
},
{
x: '2020-08-02T00:00:00.000',
xValues: ['2020-08-02T00:00:00.000'],
'Orders.count': 2,
'Australia,Users.count': 0,
'Spain,Users.count': 34,
'Italy,Users.count': 18,
},
Expand Down

0 comments on commit f28f803

Please sign in to comment.