-
Notifications
You must be signed in to change notification settings - Fork 1.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ResultSet fillMissingDates not working as expected if dimensions in the query #718
Comments
We just ran into this bug ourselves, still exists in 0.19.35. However, removing the dimension did not solve the issue for us. |
The incorrect behavior was fixed in 0.19.35. You can learn more about The only thing with the e.g. const pivotConfig = {
x: ['Orders.ts.week'],
y: ['Users.country', 'measures'],
fillMissingDates: true
} So, @0is1 in your case the values of @dvins could you please tell more about your use case? Ideally share code examples and the desired outcome. |
Hi @vasilev-alex, It's pretty basic, our pivotConfig is similar:
We then call as follows:
We can see in the call to I can share other details with you privately via the CubeJS Slack group. Will message you there. |
@dvins, it will work in your case if you put the |
Hi @vasilev-alex ! I did a quick test with the latest version ( So tableColumns() return data like this:
for query like this:
I expect tableColumns() to return:
Did there happen some kind of change to that logic also? So do I need to use some new props when using |
Actually we have fixed the incorrect behavior for As for your case you can simply pass
you can pass this config (see the docs here https://cube.dev/docs/@cubejs-client-core#pivot-config) const pivotConfig = {
x: ['Y.firstpublished.day', 'X.name'],
y: ['measures']
} But there's a limitation here, when you pass any dimension other than timeDimension ( As of now it's the expected behavior. But it would be really nice if you shared your thoughts on how it should fill missing dates? e.g. if you have this kind of data: const query = {
measures: ['Orders.count'],
dimensions: ['Users.country'],
timeDimensions: [
{
dimension: 'Orders.ts',
granularity: 'day',
dateRange: ['2020-05-01', '2020-05-31']
},
],
};
// the result of `tablePivot`
const tablePivotResult = [
{
'Users.country': 'Italy',
'Orders.ts.day': '2020-05-02T00:00:00.000',
'Orders.count': 2,
},
{
'Users.country': 'Italy',
'Orders.ts.day': '2020-05-04T00:00:00.000',
'Orders.count': 2,
},
{
'Users.country': 'US',
'Orders.ts.day': '2020-05-14T00:00:00.000',
'Orders.count': 1,
},
{
'Users.country': 'France',
'Orders.ts.day': '2020-05-01T00:00:00.000',
'Orders.count': 1,
},
{
'Users.country': 'France',
'Orders.ts.day': '2020-05-10T00:00:00.000',
'Orders.count': 1,
},
]
// after `fillMissingDates`
const res = [
{
'Users.country': 'Italy',
'Orders.ts.day': '2020-05-01T00:00:00.000',
'Orders.count': 0,
},
{
'Users.country': 'Italy',
'Orders.ts.day': '2020-05-02T00:00:00.000',
'Orders.count': 2,
},
// ...
{
'Users.country': 'Italy',
'Orders.ts.day': '2020-05-31T00:00:00.000',
'Orders.count': 0
},
{
'Users.country': 'US',
'Orders.ts.day': '2020-05-01T00:00:00.000',
'Orders.count': 0,
},
// ...
{
'Users.country': 'US',
'Orders.ts.day': '2020-05-31T00:00:00.000',
'Orders.count': 0,
},
// ...
// ...
] And what if we add even more dimensions? Like const tablePivotResult = [
{
'Users.country': 'Italy',
'Orders.status': 'shipped',
'Orders.ts.day': '2020-05-02T00:00:00.000',
'Orders.count': 2,
},
{
'Users.country': 'Italy',
'Orders.status': 'shipped',
'Orders.ts.day': '2020-05-04T00:00:00.000',
'Orders.count': 2,
},
{
'Users.country': 'US',
'Orders.status': 'pending',
'Orders.ts.day': '2020-05-14T00:00:00.000',
'Orders.count': 1,
},
{
'Users.country': 'France',
'Orders.status': 'pending',
'Orders.ts.day': '2020-05-01T00:00:00.000',
'Orders.count': 1,
},
{
'Users.country': 'France',
'Orders.status': 'shipped',
'Orders.ts.day': '2020-05-10T00:00:00.000',
'Orders.count': 1,
},
] In the example above users from Italy have all orders shipped but some users from other countries have pending orders. Should we take it into account and fill the missing dates for all possible statuses? [
{
'Users.country': 'Italy',
'Orders.status': 'shipped',
'Orders.ts.day': '2020-05-01T00:00:00.000',
'Orders.count': 0,
},
//...
{
'Users.country': 'Italy',
'Orders.status': 'pending',
'Orders.ts.day': '2020-05-01T00:00:00.000',
'Orders.count': 0,
},
//...
//...
] |
Hello! Current version |
Describe the bug
According to the documentation (https://cube.dev/docs/@cubejs-client-core#result-set-pivot)
resultSet.tablePivot()
(and other pivot methods) should havepivotConfig.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})
andresultSet.tablePivot(resultSet.normalizePivotConfig())
) return same data for this kind of query:resultSet.tablePivot(resultSet.normalizePivotConfig())
returnsEvery different
xxx.name
should havezzz.count: 0
if there’s no data on that day, right?If I add
granularity: 'day'
and useresultSet.tablePivot(resultSet.normalizePivotConfig())
then it returns zero data but only forxxx.name: "yyy"
. So there’s no data forxxx.name: "yyy2"
orxxx.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 havezzz.count: 0
if there's no data on that day when usingresultSet.tablePivot()
.Version:
Additional context
Slack conversation https://cube-js.slack.com/archives/CC0403RRR/p1591601894030200
The text was updated successfully, but these errors were encountered: