Skip to content

Commit

Permalink
fix(@cubejs-client/core): pivot should work well with null values (#1386
Browse files Browse the repository at this point in the history
). Thanks to @mspiegel31!

* fix: πŸ› pivot should work well with null values

* fix: removing timeDimensions from test data

Co-authored-by: Mike Spiegel <mike@ripplescience.com>
  • Loading branch information
mspiegel31 and Mike Spiegel committed Nov 16, 2020
1 parent 1f37fb7 commit d4c2446
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 0 deletions.
5 changes: 5 additions & 0 deletions packages/cubejs-client-core/src/ResultSet.js
Expand Up @@ -141,6 +141,11 @@ class ResultSet {
range.end
].map((dt) => dt.format(moment.HTML5_FMT.DATETIME_LOCAL_MS)),
});
} else if (value == null) {
filters.push({
member,
operator: 'notSet',
});
} else {
filters.push({
member,
Expand Down
35 changes: 35 additions & 0 deletions packages/cubejs-client-core/src/tests/drill-down.test.js
Expand Up @@ -80,6 +80,7 @@ const loadResponse = (query = {}) => ({
},
});


describe('drill down query', () => {
const resultSet1 = new ResultSet(loadResponse());
const resultSet2 = new ResultSet(
Expand All @@ -98,6 +99,12 @@ describe('drill down query', () => {
],
})
);
const resultSet4 = new ResultSet(
loadResponse({
dimensions: ["Statuses.potential"],
timeDimensions: []
}
))

it('handles a query with a time dimension', () => {
expect(
Expand Down Expand Up @@ -175,4 +182,32 @@ describe('drill down query', () => {
timezone: 'UTC',
});
});


it('handles null values', () => {
expect(
resultSet4.drillDown({ xvalues: [null] })
).toEqual(
{
measures: [],
dimensions: [
"Orders.id",
"Orders.title",
],
filters: [
{
member: "Orders.count",
operator: "measureFilter",
},
{
member: "Statuses.potential",
operator: "notSet",
},
],
timeDimensions: [],
timezone: "UTC",
}
)

})
});

0 comments on commit d4c2446

Please sign in to comment.