fix(sqla): avoid unnecessary groupby for when no metrics (#18579)
This commit is contained in:
parent
8b0634c9ed
commit
55cd7fb412
|
|
@ -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,
|
||||
)
|
||||
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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"
|
||||
|
|
|
|||
Loading…
Reference in New Issue