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

   ### 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.
   
   > Note on the classic plugin's `percent_metric_calculation = 'all_records'` 
mode: in that mode an extra all-records query is appended before the totals 
query, and `transformProps` reads the totals from `queriesData[1]` (the 
all-records query), so the dedicated totals query is not what feeds the footer 
in that mode. This change fixes the default `row_limit` mode (the common case) 
and does **not** regress `all_records` mode. Fully wiring the footer for 
`all_records` mode is a separate follow-up.
   
   ### BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF
   
   <!-- before/after screenshots: TODO -->
   
   ### 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 leave totals post_processing empty without percent metrics`
   
   ### ADDITIONAL INFORMATION
   
   - [x] Has associated issue: Fixes #37627
   - [ ] Required feature flags:
   - [x] Changes UI
   - [ ] Includes DB Migration (follow approval process in 
[SIP-59](https://github.com/apache/superset/issues/13351))
   - [ ] 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