Skip to content

fix(table): pick totals query positionally so all_records percent metrics don't shift it#42428

Open
rusackas wants to merge 2 commits into
masterfrom
fix/issue-39587-followup
Open

fix(table): pick totals query positionally so all_records percent metrics don't shift it#42428
rusackas wants to merge 2 commits into
masterfrom
fix/issue-39587-followup

Conversation

@rusackas

Copy link
Copy Markdown
Member

SUMMARY

When "Percentage metric calculation" is set to "Use all records" and "Show totals" is enabled, buildQuery inserts an extra query (used to compute percent metrics against the full result set) ahead of the totals query inside queriesData. transformProps picked the totals query by a fixed array index, so in this configuration it grabbed the percent-metrics-only query instead, and the summary/totals row ended up with the wrong values (and, since those values didn't line up with the columns' configured d3NumberFormat, effectively unformatted-looking numbers).

This locates the totals query positionally (it's always the last entry in queriesData when present) instead of assuming a fixed index, so it's no longer displaced by the extra percent-metrics query.

BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF

Not applicable — logic fix in query result wiring, not a visual/styling change.

TESTING INSTRUCTIONS

  1. Create a Table chart in Aggregate mode with at least one metric and a percent metric.
  2. Set "Percentage metric calculation" to "Use all records".
  3. Enable "Show totals".
  4. Set a custom number format on a metric column via "Customize columns".
  5. Confirm the summary/totals row now reflects the correct total (and format) for that column, rather than a value pulled from the percent-metrics query.

Also covered by a new unit test in superset-frontend/plugins/plugin-chart-table/test/TableChart.test.tsx that pins down the correct totals query is picked when the "all records" percent-metric query precedes it in queriesData.

Note: I wasn't able to run the frontend test suite in this environment (broken/hanging local node_modules), so please treat CI as the source of truth here.

ADDITIONAL INFORMATION

…rics don't shift it

`buildQuery` inserts an extra query ahead of the totals query in `queriesData`
when `percent_metric_calculation` is set to "all_records", so the fixed-index
destructuring in `transformProps` grabbed that query instead of the actual
totals query, leaving the summary row with the wrong (and unformatted) values.

Fixes #39587
@dosubot dosubot Bot added change:frontend Requires changing the frontend viz:charts:table Related to the Table chart labels Jul 26, 2026
@bito-code-review

bito-code-review Bot commented Jul 26, 2026

Copy link
Copy Markdown
Contributor

Code Review Agent Run #365a18

Actionable Suggestions - 0
Review Details
  • Files reviewed - 2 · Commit Range: 5cb1752..5cb1752
    • superset-frontend/plugins/plugin-chart-table/src/transformProps.ts
    • superset-frontend/plugins/plugin-chart-table/test/TableChart.test.tsx
  • 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

…memoized state

The added test called transformProps before the pre-existing 'render basic
data' test in the same file, evicting the module-level memoizeOne cache that
test relies on and flipping its timestamp column formatting. Relocating the
test to the end of the suite keeps it from disturbing earlier tests.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@codecov

codecov Bot commented Jul 26, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 65.24%. Comparing base (e1ffa53) to head (0bde9a7).
⚠️ Report is 3 commits behind head on master.

Additional details and impacted files
@@           Coverage Diff           @@
##           master   #42428   +/-   ##
=======================================
  Coverage   65.24%   65.24%           
=======================================
  Files        2795     2795           
  Lines      157643   157649    +6     
  Branches    36061    36066    +5     
=======================================
+ Hits       102853   102859    +6     
  Misses      52814    52814           
  Partials     1976     1976           
Flag Coverage Δ
javascript 71.27% <100.00%> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@bito-code-review

bito-code-review Bot commented Jul 26, 2026

Copy link
Copy Markdown
Contributor

Code Review Agent Run #ca1589

Actionable Suggestions - 0
Review Details
  • Files reviewed - 1 · Commit Range: 5cb1752..0bde9a7
    • superset-frontend/plugins/plugin-chart-table/test/TableChart.test.tsx
  • Files skipped - 0
  • Tools
    • 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

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

Labels

change:frontend Requires changing the frontend plugins size/M viz:charts:table Related to the Table chart

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Table Chart: Number formatting not applied to summary line

1 participant