codeant-ai-for-open-source[bot] commented on code in PR #43027:
URL: https://github.com/apache/superset/pull/43027#discussion_r3761918564
##########
tests/integration_tests/non_additive_totals_tests.py:
##########
@@ -189,6 +189,48 @@ def
test_backend_computes_percent_column_for_summary_query(self):
assert totals_df["sum__num_pct"].iloc[0] == pytest.approx(1.0)
[email protected]("load_birth_names_dashboard_with_slices")
+class TestTableTotalsAggregateOverride(SupersetTestCase):
+ """
+ #43021: "Show summary" lets a user choose the totals row's aggregation
+ (Sum or Average) independently of each metric's own aggregation. The
+ frontend (``getTotalsMetrics``) implements this by cloning a SIMPLE
+ metric with its ``aggregate`` swapped for just the totals query. Since
+ that query has no GROUP BY, the database evaluates the swapped
+ aggregate fresh over every row -- this guard pins that an AVG override
+ is a true row-level average (SUM / COUNT over all rows), not the
+ metric's own SUM aggregation and not a naive average of per-group sums.
+ """
+
+ def test_avg_totals_aggregate_matches_sum_over_count(self):
+ self.login("admin")
+
+ sum_metric = {
+ "expressionType": "SIMPLE",
+ "column": {"column_name": "num"},
+ "aggregate": "SUM",
+ "label": "sum__num",
+ }
+ count_metric = {
+ "expressionType": "SIMPLE",
+ "column": {"column_name": "num"},
+ "aggregate": "COUNT",
+ "label": "count__num",
+ }
+ avg_metric = {**sum_metric, "aggregate": "AVG", "label": "avg__num"}
+
+ total_sum = _result_df(_base_payload(sum_metric,
[]))["sum__num"].iloc[0]
+ total_count = _result_df(_base_payload(count_metric,
[]))["count__num"].iloc[0]
+ avg_total = _result_df(_base_payload(avg_metric,
[]))["avg__num"].iloc[0]
Review Comment:
✅ **Customized review instruction saved!**
**Instruction:**
> Do not require focused database integration tests to duplicate frontend
wiring coverage when dedicated unit tests already verify the wiring; evaluate
them against their documented behavior, such as validating row-level AVG
correctness.
**Applied to:**
- `**/test/**`
- `**/tests/**`
- `**/*test*.py`
---
💡 *To manage or update this instruction, visit: [CodeAnt AI
Settings](https://app.codeant.ai/org/settings/learnings)*
--
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]