From 00164385a96dde184cdd32d297e55a41c2f961f1 Mon Sep 17 00:00:00 2001 From: Alex Vasilev Date: Mon, 15 Nov 2021 18:52:22 +0300 Subject: [PATCH] fix(client-core): nullish measure values --- packages/cubejs-client-core/src/ResultSet.js | 4 +--- packages/cubejs-client-core/src/tests/ResultSet.test.js | 5 ++--- packages/cubejs-client-core/src/tests/data-blending.test.js | 3 +++ 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/packages/cubejs-client-core/src/ResultSet.js b/packages/cubejs-client-core/src/ResultSet.js index c71cc448d0cb8..9404628dc94a8 100644 --- a/packages/cubejs-client-core/src/ResultSet.js +++ b/packages/cubejs-client-core/src/ResultSet.js @@ -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 && @@ -379,8 +379,6 @@ class ResultSet { ); return series[resultIndex].map(d => [d, byXValues[d] || [{ xValues: [d], row: {} }]]); }; - - measureValue = (row, measure) => row[measure] || 0; } } diff --git a/packages/cubejs-client-core/src/tests/ResultSet.test.js b/packages/cubejs-client-core/src/tests/ResultSet.test.js index 90aa7f640f6c9..ded3ae9fe7eb2 100644 --- a/packages/cubejs-client-core/src/tests/ResultSet.test.js +++ b/packages/cubejs-client-core/src/tests/ResultSet.test.js @@ -187,7 +187,7 @@ describe('ResultSet', () => { { x: 'Name 1', - 'Foo.count': null, + 'Foo.count': 0, xValues: [ 'Name 1' ], @@ -235,8 +235,7 @@ describe('ResultSet', () => { expect(resultSet.chartPivot()).toEqual([ { x: 'Name 1', - - 'Foo.count': undefined, + 'Foo.count': 0, xValues: [ 'Name 1' ], diff --git a/packages/cubejs-client-core/src/tests/data-blending.test.js b/packages/cubejs-client-core/src/tests/data-blending.test.js index e93d337b96370..e3eb42c96d161 100644 --- a/packages/cubejs-client-core/src/tests/data-blending.test.js +++ b/packages/cubejs-client-core/src/tests/data-blending.test.js @@ -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, },