veeceey opened a new pull request, #37987:
URL: https://github.com/apache/superset/pull/37987

   ### SUMMARY
   
   When using both resampling (e.g., "1 calendar day frequency" with zero 
imputation) and a rolling window function (e.g., rolling mean) on time-series 
charts, the results come out wrong — you get a stepped graph alternating 
between the original values and zero instead of a smooth rolling curve.
   
   The root cause is that the rolling window operator was being applied 
*before* the resample operator in the post-processing pipeline. This means the 
rolling calculation runs on the sparse original data, and then resampling fills 
in zeros afterward — which defeats the purpose. The correct order is to 
resample first (filling gaps with zeros or other imputation), and then apply 
the rolling window over that complete series.
   
   This swaps the order in all three affected chart types:
   - **Timeseries** (line, bar, area, step)
   - **MixedTimeseries** (dual-axis)
   - **BigNumberWithTrendline**
   
   ### BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF
   
   **Before** (from issue report): stepped graph with values jumping between 5 
and 0
   
![before](https://user-images.githubusercontent.com/108309305/218611115-b343b6b9-039c-4a23-9855-0dd19af974a0.png)
   
   **Expected** (smooth rolling mean curve):
   
![expected](https://user-images.githubusercontent.com/108309305/218612718-10fd72e0-3966-4bc6-8081-360184505077.png)
   
   ### TESTING INSTRUCTIONS
   
   1. Upload 
[demo.csv](https://github.com/apache/superset/files/10727554/demo.csv) from the 
issue as a dataset
   2. Create a Time-series Line Chart, set metric to AVG(value)
   3. Under Advanced Analytics, set resampling to "1 calendar day frequency" 
with "Zero imputation"
   4. Set rolling window function to "mean" with period and min periods = 5
   5. Update chart — should now show a smooth rolling curve instead of the 
stepped pattern
   
   ### ADDITIONAL INFORMATION
   
   - [x] Has associated issue: Fixes #23072
   - [ ] Required feature flags:
   - [ ] Changes UI
   - [ ] Includes DB Migration (follow approval process in 
[SIP-59](https://github.com/apache/superset/issues/13351))
     - [ ] Migration is atomic, supports rollback & is backwards-compatible
     - [ ] Confirm DB migration upgrade and downgrade tested
     - [ ] Runtime estimates and downtime expectations provided
   - [ ] Introduces new feature or API
   - [ ] Removes existing feature or API


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to