-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Description
Describe the bug
According to the documentation (https://cube.dev/docs/@cubejs-client-core#result-set-pivot) resultSet.tablePivot() (and other pivot methods) should have pivotConfig.fillMissingDates true by default.
It seems that there's some sort of bug if dimensions are set to the query. All these (resultSet.tablePivot(), resultSet.tablePivot({fillMissingDates: false}) and resultSet.tablePivot(resultSet.normalizePivotConfig())) return same data for this kind of query:
{
dimensions: ["xxx.name", "Dates.date"],
filters: [],
measures: ["zzz.count"],
offset: 0,
timeDimensions: [{
dateRange: ["2020-06-04T00:00:00.000", "2020-06-10T23:59:59.999"],
dimension: "Dates.date"
}],
timezone: "Europe/Helsinki"
}
resultSet.tablePivot(resultSet.normalizePivotConfig()) returns
[
{xxx.name: "yyy", Dates.date: "2020-06-04T00:00:00.000", zzz.count: "1"},
{xxx.name: "yyy", Dates.date: "2020-06-07T00:00:00.000", zzz.count: "1"},
{xxx.name: "yyy", Dates.date: "2020-06-09T00:00:00.000", zzz.count: "1"},
{xxx.name: "yyy2", Dates.date: "2020-06-04T00:00:00.000", zzz.count: "1"},
{xxx.name: "yyy2", Dates.date: "2020-06-07T00:00:00.000", zzz.count: "1"},
{xxx.name: "yyy2", Dates.date: "2020-06-09T00:00:00.000", zzz.count: "1"},
{xxx.name: "yyy2", Dates.date: "2020-06-04T00:00:00.000", zzz.count: "1"},
{xxx.name: "yyy2", Dates.date: "2020-06-07T00:00:00.000", zzz.count: "1"},
{xxx.name: "yyy2", Dates.date: "2020-06-09T00:00:00.000", zzz.count: "1"},
{xxx.name: "yyy3", Dates.date: "2020-06-04T00:00:00.000", zzz.count: "1"},
{xxx.name: "yyy3", Dates.date: "2020-06-07T00:00:00.000", zzz.count: "1"},
{xxx.name: "yyy3", Dates.date: "2020-06-09T00:00:00.000", zzz.count: "1"},
]
Every different xxx.name should have zzz.count: 0 if there’s no data on that day, right?
If I add granularity: 'day' and use resultSet.tablePivot(resultSet.normalizePivotConfig()) then it returns zero data but only for xxx.name: "yyy". So there’s no data for xxx.name: "yyy2" or xxx.name: "yyy3" in that case.
To Reproduce
See example type of query above. You need to have data with count values >= 0 and use some dimensions. If you don't include any dimensions to the query, this is working as expected.
Expected behavior
All dimension xxx.name values should have zzz.count: 0 if there's no data on that day when using resultSet.tablePivot().
Version:
"@cubejs-client/core": "^0.19.22",
"@cubejs-client/react": "^0.19.22",
Additional context
Slack conversation https://cube-js.slack.com/archives/CC0403RRR/p1591601894030200