fitzee opened a new pull request, #44679: URL: https://github.com/apache/superset/pull/44679
## TL;DR Extract the backend result-aggregation work from #44647 into a focused follow-up to #44660. This adds the reducers used by tabular exports and reports, with each summary calculated from its original grouped metric results. Shared totals that combine different metrics stay blank. Fractions use their own metric's denominator. ### SUMMARY #44660 restores the browser aggregation control. The Python export path needs the corresponding result calculations so selecting Median or Sample Variance can also produce the intended summary outside the browser. This draft preserves that work from #44647 while removing its frontend controls, translation changes and migration concerns. It covers the 18 result choices, independent subtotal visibility, stored GROUPING SETS inputs and fraction formatting. The implementation and regression tests are kept together because they define the calculation contract. **Dependencies and remaining decisions:** - Coordinate with #44660 before merging. The old saved `aggregateFunction` becomes an active result selection in both paths. - The small Actual Values database-rollup guard overlaps with #44631. Once that merges, retain its correction for metric-definition mode. Tests in #44631 that use `aggregateFunction: "Average"` to mean database totals must switch to `Metric`; Average now requests a second aggregation pass. - Numeric nulls are ignored here. At #44660 revision `66ccb82b`, the reused JavaScript Median reducer coerces null to zero. Null/text handling, including First/Last, needs an agreed contract and browser/export checks. - This extraction retains the separate `showValuesAs` transform from #44647. #44660 currently gives its result factory precedence over that transform. Settle that behavior before claiming complete parity. ### BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF No frontend changes in this PR. For grouped values 1, 9, 20 and 100, the exported grand Median is 14.5, calculated directly from those values. A shared total across distinct metrics is blank rather than combining their values. ### TESTING INSTRUCTIONS Run: ```sh pytest tests/unit_tests/charts/test_client_processing.py -q ``` **158 tests pass**, including: - Average and Median computed from original results rather than intermediate subtotals. - All 12 non-fraction reducers and all six Sum/Count fraction choices. - Fractions with two metrics, both metric layouts and both combined-metric settings; the second metric cannot dilute the first metric's denominator. - Blank mixed-metric corners, transposition, nulls, subtotal visibility and stored database rollups. Staged-file checks and changed-module Pylint pass. Live CSV/Excel downloads, scheduled report query rebuilding after the migration, and large-result performance remain to be verified. ### ADDITIONAL INFORMATION This affects the Pivot Table v2 client-processing/export path. No database migration, new feature flag or SQL metric rewrite is included. Reverting removes this backend behavior; it does not alter chart metadata. Keep this in draft until the frontend calculation contract and integration checks above are settled. #44647 remains open while the extraction is reviewed. - [ ] Has associated issue - [ ] Required feature flags - [ ] Changes UI - [ ] Includes DB Migration - [x] 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]
