diff --git a/superset/charts/schemas.py b/superset/charts/schemas.py index 225410eb4..b25f9712d 100644 --- a/superset/charts/schemas.py +++ b/superset/charts/schemas.py @@ -598,7 +598,10 @@ class ChartDataBoxplotOptionsSchema(ChartDataPostProcessingOperationOptionsSchem description="Aggregate expressions. Metrics can be passed as both " "references to datasource metrics (strings), or ad-hoc metrics" "which are defined only within the query object. See " - "`ChartDataAdhocMetricSchema` for the structure of ad-hoc metrics.", + "`ChartDataAdhocMetricSchema` for the structure of ad-hoc metrics. " + "When metrics is undefined or null, the query is executed without a groupby. " + "However, when metrics is an array (length >= 0), a groupby clause is added to " + "the query.", allow_none=True, ) diff --git a/superset/common/query_actions.py b/superset/common/query_actions.py index 6ed18d195..ecdf00d08 100644 --- a/superset/common/query_actions.py +++ b/superset/common/query_actions.py @@ -140,7 +140,7 @@ def _get_samples( query_obj = copy.copy(query_obj) query_obj.is_timeseries = False query_obj.orderby = [] - query_obj.metrics = [] + query_obj.metrics = None query_obj.post_processing = [] query_obj.columns = [o.column_name for o in datasource.columns] query_obj.from_dttm = None diff --git a/tests/integration_tests/charts/data/api_tests.py b/tests/integration_tests/charts/data/api_tests.py index 8d9797f67..d6ccd6aad 100644 --- a/tests/integration_tests/charts/data/api_tests.py +++ b/tests/integration_tests/charts/data/api_tests.py @@ -154,6 +154,7 @@ class TestPostChartDataApi(BaseTestChartDataApi): # assert self.assert_row_count(rv, expected_row_count) + assert "GROUP BY" not in rv.json["result"][0]["query"] @pytest.mark.usefixtures("load_birth_names_dashboard_with_slices") @mock.patch( @@ -184,6 +185,7 @@ class TestPostChartDataApi(BaseTestChartDataApi): # assert self.assert_row_count(rv, expected_row_count) + assert "GROUP BY" not in rv.json["result"][0]["query"] @pytest.mark.usefixtures("load_birth_names_dashboard_with_slices") @mock.patch( @@ -200,6 +202,7 @@ class TestPostChartDataApi(BaseTestChartDataApi): # assert self.assert_row_count(rv, expected_row_count) + assert "GROUP BY" not in rv.json["result"][0]["query"] def test_with_incorrect_result_type__400(self): self.query_context_payload["result_type"] = "qwerty"