Skip to content

fix(plugin-chart-ag-grid-table): show correct percent-metric totals in summary row#41247

Open
kgabryje wants to merge 2 commits into
apache:masterfrom
kgabryje:fix-table-percent-metric-summary-totals
Open

fix(plugin-chart-ag-grid-table): show correct percent-metric totals in summary row#41247
kgabryje wants to merge 2 commits into
apache:masterfrom
kgabryje:fix-table-percent-metric-summary-totals

Conversation

@kgabryje

@kgabryje kgabryje commented Jun 19, 2026

Copy link
Copy Markdown
Member

SUMMARY

In the Interactive Table (Table V2 / plugin-chart-ag-grid-table) and the classic Table (plugin-chart-table) charts, when a metric is added to the Percentage Metrics control and Show Summary (show_totals) is enabled, the summary/totals (footer) row rendered 0.000% in every percentage column. Regular data rows were correct — only the totals row was wrong.

Root cause: The main query builds a contribution post-processing operation that renames percent-metric columns metric%metric, and transformProps (and the footer cell) looks values up by the %-prefixed key. The separate totals query (built when show_totals + aggregate query mode) hardcoded post_processing: [], so its response was keyed metric instead of %metric. The footer lookup missed and fell back to 0.000%.

Fix: Capture the percent-metric contribution rule when building the main query and reapply only that rule to the totals query's post_processing. Running contribution on the single aggregated totals row yields value/value = 100% per percent column, so the footer now shows 100.000% (the sum of all rows' percentage contributions). The main query's time-comparison operator is deliberately not carried over — it must not run against the single-row totals query.

Both the AG-Grid plugin and the classic table plugin had the identical post_processing: [] bug and both are fixed symmetrically.

KNOWN LIMITATION / FOLLOW-UP

This PR fixes the percent-metric summary/footer for:

It does not fix the classic Table in the non-default percent_metric_calculation = 'all_records' mode when show_totals is also enabled. That case is a separate, pre-existing bug with a different root cause: in all_records mode an extra all-records query is appended, and transformProps reads the footer percent from that query by fixed position (queriesData[1]/[2]), not from the dedicated totals query this PR corrects. Properly wiring the footer for all_records mode requires changes to the positional query indexing in transformProps and is left for a follow-up. This PR does not regress that mode.

BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF

TESTING INSTRUCTIONS

  1. Create a Table (or Table V2 / Interactive Table) chart in Aggregate mode.
  2. Add a metric to Metrics and the same (or another) metric to Percentage Metrics.
  3. Enable Show Summary under the Options/Customize section.
  4. Run the chart and observe the footer/totals row: the percentage column now shows 100.000% instead of 0.000%.

Automated tests (jest) were added in both plugins' test/buildQuery.test.ts:

  • ag-grid: should reapply percent-metric contribution op to totals query, should omit time-comparison op from totals post_processing, should leave totals post_processing empty without percent metrics
  • classic: should reapply contribution op to totals query in row_limit mode, should omit time-comparison op from totals post_processing, should leave totals post_processing empty without percent metrics

ADDITIONAL INFORMATION

…n summary row

When a metric is added to Percentage Metrics and Show Summary
(show_totals) is enabled, the totals/footer row rendered 0.000% in the
percentage column. The totals query hardcoded post_processing: [], so its
response was keyed `metric` instead of the `%metric` key the footer looks
up.

Capture the percent-metric `contribution` rule from the main query and
reapply only that rule to the totals query's post_processing, so the
single aggregated totals row exposes `%metric` keys (value/value = 100%).
The main query's time-comparison operator is deliberately not carried
over to the single-row totals query.

The classic plugin-chart-table had the identical bug and is fixed
symmetrically (default row_limit calculation mode).

Fixes apache#37627

Signed-off-by: Kamil Gabryjelski <kamil.gabryjelski@gmail.com>
@dosubot dosubot Bot added the viz:charts:table Related to the Table chart label Jun 19, 2026
@bito-code-review

bito-code-review Bot commented Jun 19, 2026

Copy link
Copy Markdown
Contributor

Code Review Agent Run #bd4eba

Actionable Suggestions - 0
Review Details
  • Files reviewed - 4 · Commit Range: d90bf11..d90bf11
    • superset-frontend/plugins/plugin-chart-ag-grid-table/src/buildQuery.ts
    • superset-frontend/plugins/plugin-chart-ag-grid-table/test/buildQuery.test.ts
    • superset-frontend/plugins/plugin-chart-table/src/buildQuery.ts
    • superset-frontend/plugins/plugin-chart-table/test/buildQuery.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

@codecov

codecov Bot commented Jun 19, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 64.37%. Comparing base (f545d70) to head (65a8297).

Additional details and impacted files
@@            Coverage Diff             @@
##           master   #41247      +/-   ##
==========================================
+ Coverage   64.36%   64.37%   +0.01%     
==========================================
  Files        2651     2651              
  Lines      144812   144812              
  Branches    33417    33417              
==========================================
+ Hits        93208    93227      +19     
+ Misses      49935    49916      -19     
  Partials     1669     1669              
Flag Coverage Δ
javascript 68.57% <100.00%> (+0.02%) ⬆️

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.

Mirror the ag-grid regression test: with a time comparison active
alongside percent metrics and show_totals, the classic table's totals
query must carry the percent-metric contribution op but not the
time-comparison operator.

Signed-off-by: Kamil Gabryjelski <kamil.gabryjelski@gmail.com>
@bito-code-review

bito-code-review Bot commented Jun 19, 2026

Copy link
Copy Markdown
Contributor

Code Review Agent Run #e992ae

Actionable Suggestions - 0
Review Details
  • Files reviewed - 1 · Commit Range: d90bf11..65a8297
    • superset-frontend/plugins/plugin-chart-table/test/buildQuery.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

@eschutho eschutho requested a review from betodealmeida June 22, 2026 07:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

plugins size/L viz:charts:table Related to the Table chart

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Percentage metrics column display only zero value

1 participant