Skip to content
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

Advanced Analytics time shift '1 year' not parsing correctly #7311

Closed
2 of 3 tasks
michellethomas opened this issue Apr 16, 2019 · 1 comment · Fixed by #7616
Closed
2 of 3 tasks

Advanced Analytics time shift '1 year' not parsing correctly #7311

michellethomas opened this issue Apr 16, 2019 · 1 comment · Fixed by #7616
Labels
!deprecated-label:bug Deprecated label - Use #bug instead P1 Priority item - Major v0.31

Comments

@michellethomas
Copy link
Contributor

On a line chart using the advanced analytics with time shift 1 year incorrectly evaluates to 366 days as the delta and as a result shows incorrect data. 2020 is a leap year, parse_human_timedelta given s of 1 year evaluates to 366 days which is correct given that it's doing d - dttm but in run_extra_queries the delta is calculated from 1 year, which gets evaluated to 1 year in the future (366 days) instead of 1 year in the past (365 days).

Related to this issue, in get_data we are doing df2.reindex(combined_index).interpolate(method='time').reindex(df.index), I'm not sure when this is necessary and I think instead of reindexing we should just throw an error if the dates won't match up in df2 and df. I've debugged problems with this in the past and it's really difficult for users to understand if they are doing a comparison that doesn't make sense. If your granularity is month and you are doing a time shift of 52 weeks the dates for actual values and time shifted values don't match up correctly they get interpolated in a way that will change each of the time shifted values. This shifted data ends up being incorrect (but doesn't look off enough to be obvious) which could result in people reporting incorrect information without realizing.

Expected results

Time shift 1 year results in a delta of 365 days.

Actual results

Time shift 1 year results in a delta of 366 days.

How to reproduce the bug

  1. Create a line chart grouping by month
  2. Under advanced analytics add time shift '1 year', calculation type "Absolute Difference"
  3. Check the results against the actual monthly values
  4. Difference numbers using advanced analytics don't match difference in actual values

Environment

(please complete the following information):

  • superset version: 0.31
  • python version: 3.6

Checklist

Make sure these boxes are checked before submitting your issue - thank you!

  • I have checked the superset logs for python stacktraces and included it here as text if there are any.
  • I have reproduced the issue with at least the latest released version of superset.
  • I have checked the issue tracker for the same issue and I haven't found one similar.

@john-bodley @mistercrunch @betodealmeida

I can work on a fix, just wanted to give a heads up because you have worked on this before and may have some thoughts.

@michellethomas michellethomas changed the title Time shift 1 year not parsing correctly Advanced Analytics time shift '1 year' not parsing correctly Apr 16, 2019
@michellethomas michellethomas added !deprecated-label:bug Deprecated label - Use #bug instead P1 Priority item - Major v0.31 v0.33 and removed v0.33 labels May 24, 2019
@michellethomas
Copy link
Contributor Author

Setting this as a P1 bug because we are showing incorrect information to users based on the controls.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
!deprecated-label:bug Deprecated label - Use #bug instead P1 Priority item - Major v0.31
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant