Skip to content

Comments

fix(charts): apply resample before rolling window in post-processing pipeline#37987

Open
veeceey wants to merge 2 commits intoapache:masterfrom
veeceey:fix/issue-23072-rolling-resample-order
Open

fix(charts): apply resample before rolling window in post-processing pipeline#37987
veeceey wants to merge 2 commits intoapache:masterfrom
veeceey:fix/issue-23072-rolling-resample-order

Conversation

@veeceey
Copy link

@veeceey veeceey commented Feb 15, 2026

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

Expected (smooth rolling mean curve):
expected

TESTING INSTRUCTIONS

  1. Upload 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

  • Has associated issue: Fixes Rolling mean on resampled data produces incorrect graph #23072
  • Required feature flags:
  • Changes UI
  • Includes DB Migration (follow approval process in SIP-59)
    • 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

@bito-code-review
Copy link
Contributor

bito-code-review bot commented Feb 15, 2026

Code Review Agent Run #b46558

Actionable Suggestions - 0
Review Details
  • Files reviewed - 4 · Commit Range: bfd6b7b..bfd6b7b
    • superset-frontend/plugins/plugin-chart-echarts/src/BigNumber/BigNumberWithTrendline/buildQuery.test.ts
    • superset-frontend/plugins/plugin-chart-echarts/src/BigNumber/BigNumberWithTrendline/buildQuery.ts
    • superset-frontend/plugins/plugin-chart-echarts/src/MixedTimeseries/buildQuery.ts
    • superset-frontend/plugins/plugin-chart-echarts/src/Timeseries/buildQuery.ts
  • Files skipped - 0
  • Tools
    • Whispers (Secret Scanner) - ✔︎ Successful
    • Detect-secrets (Secret Scanner) - ✔︎ Successful
    • Eslint (Linter) - ✔︎ Successful

Bito Usage Guide

Commands

Type the following command in the pull request comment and save the comment.

  • /review - Manually triggers a full AI review.

  • /pause - Pauses automatic reviews on this pull request.

  • /resume - Resumes automatic reviews.

  • /resolve - Marks all Bito-posted review comments as resolved.

  • /abort - Cancels all in-progress reviews.

Refer to the documentation for additional commands.

Configuration

This repository uses Superset You can customize the agent settings here or contact your Bito workspace admin at evan@preset.io.

Documentation & Help

AI Code Review powered by Bito Logo

Copy link
Contributor

@alexandrusoare alexandrusoare left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM - can you also provide a screenshot of the After? I am curious of how it looks

@veeceey
Copy link
Author

veeceey commented Feb 20, 2026

Sure thing @alexandrusoare! I'll add an After screenshot shortly.

@veeceey
Copy link
Author

veeceey commented Feb 20, 2026

Thanks for the approval @alexandrusoare! I don't currently have a local Superset dev environment set up to grab a screenshot since the changes are in the query builder layer (not visual). The fix ensures that when x_axis is set, the granularity_sqla temporal column is excluded from the GROUP BY clause, so the visible difference would be in the generated SQL query rather than the chart UI itself.

If you'd still like a visual, I can spin up the dev environment and show the SQL output before/after — let me know!

@bito-code-review
Copy link
Contributor

bito-code-review bot commented Feb 20, 2026

Code Review Agent Run #3c327b

Actionable Suggestions - 0
Review Details
  • Files reviewed - 6 · Commit Range: bfd6b7b..21ad31a
    • superset-frontend/plugins/plugin-chart-echarts/src/BigNumber/BigNumberWithTrendline/buildQuery.test.ts
    • superset-frontend/plugins/plugin-chart-echarts/src/BigNumber/BigNumberWithTrendline/buildQuery.ts
    • superset-frontend/plugins/plugin-chart-echarts/src/MixedTimeseries/buildQuery.ts
    • superset-frontend/plugins/plugin-chart-echarts/src/Timeseries/buildQuery.ts
    • superset-frontend/plugins/plugin-chart-echarts/test/MixedTimeseries/transformProps.test.ts
    • superset-frontend/plugins/plugin-chart-echarts/test/Timeseries/transformProps.test.ts
  • Files skipped - 0
  • Tools
    • Eslint (Linter) - ✔︎ Successful
    • Whispers (Secret Scanner) - ✔︎ Successful
    • Detect-secrets (Secret Scanner) - ✔︎ Successful

Bito Usage Guide

Commands

Type the following command in the pull request comment and save the comment.

  • /review - Manually triggers a full AI review.

  • /pause - Pauses automatic reviews on this pull request.

  • /resume - Resumes automatic reviews.

  • /resolve - Marks all Bito-posted review comments as resolved.

  • /abort - Cancels all in-progress reviews.

Refer to the documentation for additional commands.

Configuration

This repository uses Superset You can customize the agent settings here or contact your Bito workspace admin at evan@preset.io.

Documentation & Help

AI Code Review powered by Bito Logo

veeceey and others added 2 commits February 19, 2026 23:49
…pipeline

When both resampling and rolling window are used on time-series charts,
the rolling calculation was applied before resampling. This meant that
imputed/zero-filled values from resampling were not included in the
rolling window, producing incorrect stepped graphs instead of smooth
curves.

Reorder the post-processing pipeline in Timeseries, MixedTimeseries,
and BigNumberWithTrendline chart types so that resample runs before
rolling window, matching the mathematically correct sequence.

Closes apache#23072
… lint errors

Replace `formulaSeries?.data` with `formulaSeries!.data` in type assertion
contexts where optional chaining produces unsafe undefined values. The
`formulaSeries` variable is already validated via `expect().toBeDefined()`
before these lines.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@veeceey veeceey force-pushed the fix/issue-23072-rolling-resample-order branch from 21ad31a to 6c6d5da Compare February 20, 2026 07:50
@bito-code-review
Copy link
Contributor

bito-code-review bot commented Feb 20, 2026

Code Review Agent Run #65500d

Actionable Suggestions - 0
Review Details
  • Files reviewed - 6 · Commit Range: 956d5c1..6c6d5da
    • superset-frontend/plugins/plugin-chart-echarts/src/BigNumber/BigNumberWithTrendline/buildQuery.test.ts
    • superset-frontend/plugins/plugin-chart-echarts/src/BigNumber/BigNumberWithTrendline/buildQuery.ts
    • superset-frontend/plugins/plugin-chart-echarts/src/MixedTimeseries/buildQuery.ts
    • superset-frontend/plugins/plugin-chart-echarts/src/Timeseries/buildQuery.ts
    • superset-frontend/plugins/plugin-chart-echarts/test/MixedTimeseries/transformProps.test.ts
    • superset-frontend/plugins/plugin-chart-echarts/test/Timeseries/transformProps.test.ts
  • Files skipped - 0
  • Tools
    • Whispers (Secret Scanner) - ✔︎ Successful
    • Detect-secrets (Secret Scanner) - ✔︎ Successful
    • Eslint (Linter) - ✔︎ Successful

Bito Usage Guide

Commands

Type the following command in the pull request comment and save the comment.

  • /review - Manually triggers a full AI review.

  • /pause - Pauses automatic reviews on this pull request.

  • /resume - Resumes automatic reviews.

  • /resolve - Marks all Bito-posted review comments as resolved.

  • /abort - Cancels all in-progress reviews.

Refer to the documentation for additional commands.

Configuration

This repository uses Superset You can customize the agent settings here or contact your Bito workspace admin at evan@preset.io.

Documentation & Help

AI Code Review powered by Bito Logo

@veeceey
Copy link
Author

veeceey commented Feb 23, 2026

Good question! Since this is a backend fix to the post-processing pipeline order (applying resample before rolling window instead of after), the chart visually looks the same—it's the underlying computed values that change.

The Before showed incorrect aggregation because rolling was applied to un-resampled data, and the After shows correct values with proper resampling applied first. The data values in the table should be different, but the chart rendering itself is identical.

Happy to add a data value comparison if that would be helpful!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Rolling mean on resampled data produces incorrect graph

2 participants