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

   ### SUMMARY
   
   Draft SIP + **prototype development zone** for fixing one of Superset's
   longest-standing correctness gaps: **totals and subtotals are wrong for
   non-additive metrics** (ratios, `COUNT_DISTINCT`, `AVG`, percentiles, and
   "Percentage metrics") in both the Table and Pivot Table charts.
   
   The proposal lives in [`SIP.md`](SIP.md). This PR is intentionally a draft so
   the SIP, a failing-test matrix of the known reported cases, and the POC
   implementation can be rounded out together (TDD: the POC drives the matrix
   green).
   
   **Core principle:** totals must be computed by the DB at the grouping
   granularity, never by re-aggregating already-aggregated cells. A SQL 
aggregate
   metric is correct at any grouping level if the same expression is evaluated
   grouped at that level, so no formula language is needed for the common cases.
   
   **Approach:** detect additivity (additive-only = current cheap path, 
unchanged)
   → for non-additive, compute rollup levels via native `GROUPING SETS` in a
   single query → fall back to multi-query (the #34592 approach) on engines 
lacking
   a new `supports_grouping_sets` capability → recompute (don't sum) 
post-processing
   % columns → one shared mechanism for Table + Pivot.
   
   Consolidates: #25747 (canonical), #32260, #38674, #36165, #37627,
   #34350/#34425/#34426. Design thread: #29297. Builds on prior art in #34592.
   
   Out of scope: #39223, SIP-179 (#34245), #35089, SIP-205 (#38586).
   
   ### BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF
   
   N/A (proposal/scaffold).
   
   ### TESTING INSTRUCTIONS
   
   The TDD acceptance matrix is in `SIP.md` (§ Validation / TDD test matrix).
   Failing tests and POC to follow in this PR.
   
   ### ADDITIONAL INFORMATION
   
   - [ ] Has associated issue: relates to #25747, #29297
   - [x] Required feature flags: TBD (possible opt-in flag during rollout)
   - [ ] Changes UI
   - [ ] Includes DB Migration (please mention transaction, lock, and revert 
plan)
   - [ ] Introduces new feature or API
   - [ ] Removes existing feature or API
   
   > Draft — not for review yet. Opening early as a shared SIP + prototype 
space.
   


-- 
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