bito-code-review[bot] commented on code in PR #40954:
URL: https://github.com/apache/superset/pull/40954#discussion_r3803525976
##########
tests/integration_tests/charts/data/api_tests.py:
##########
@@ -613,6 +613,41 @@ def test_chart_data_prophet(self):
assert "sum__num__yhat_lower" in row
assert result["rowcount"] == 103
+ @pytest.mark.usefixtures("load_birth_names_dashboard_with_slices")
+ def test_chart_data_anomaly_detection(self):
+ """
+ Chart data API: Ensure anomaly detection post transformation works
+ """
+ if backend() == "hive":
+ return
+
+ time_grain = "P1Y"
+ self.query_context_payload["queries"][0]["is_timeseries"] = True
+ self.query_context_payload["queries"][0]["groupby"] = []
+ self.query_context_payload["queries"][0]["extras"] = {
+ "time_grain_sqla": time_grain
+ }
+ self.query_context_payload["queries"][0]["granularity"] = "ds"
+ self.query_context_payload["queries"][0]["post_processing"] = [
+ {
+ "operation": "anomaly_detection",
+ "options": {
+ "method": "zscore",
+ "rolling_window": 7,
+ "sensitivity": 3.0,
+ },
+ }
+ ]
+ rv = self.post_assert_metric(CHART_DATA_URI,
self.query_context_payload, "data")
+ assert rv.status_code == 200
+ response_payload = json.loads(rv.data.decode("utf-8"))
+ result = response_payload["result"][0]
+ row = result["data"][0]
+ assert "__timestamp" in row
+ assert "sum__num" in row
+ # Anomaly columns should be present
+ assert "sum__num__anomaly" in row
Review Comment:
<div>
<div id="suggestion">
<div id="issue"><b>Inconsistent assertion coverage</b></div>
<div id="fix">
The test verifies anomaly column presence but omits the `rowcount` assertion
present in the parallel `test_chart_data_prophet` test (line 614). Inconsistent
assertions may allow data processing bugs to go undetected.
</div>
</div>
<small><i>Code Review Run #5adae1</i></small>
</div>
---
Should Bito avoid suggestions like this for future reviews? (<a
href=https://alpha.bito.ai/home/ai-agents/review-rules>Manage Rules</a>)
- [ ] Yes, avoid them
##########
superset-frontend/plugins/plugin-chart-echarts/src/Timeseries/buildQuery.ts:
##########
@@ -32,6 +32,7 @@ import {
isTimeComparison,
pivotOperator,
prophetOperator,
+ anomalyDetectionOperator,
Review Comment:
<div>
<div id="suggestion">
<div id="issue"><b>Missing test coverage for new operator</b></div>
<div id="fix">
The test file `test/Timeseries/buildQuery.test.ts` at lines 104-116 and
139-150 uses exact `toEqual` with `expect.objectContaining` that checks full
`post_processing` arrays. Adding `anomalyDetectionOperator` at line 119 will
cause these assertions to fail because the actual result will have an
additional element not present in the expected output.
</div>
</div>
<small><i>Code Review Run #5adae1</i></small>
</div>
---
Should Bito avoid suggestions like this for future reviews? (<a
href=https://alpha.bito.ai/home/ai-agents/review-rules>Manage Rules</a>)
- [ ] Yes, avoid them
--
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]