From 8069d6221d943694f544a2977deac1089176189a Mon Sep 17 00:00:00 2001 From: Maxime Beauchemin Date: Fri, 12 Jan 2018 11:29:24 -0800 Subject: [PATCH] [druid] fix 2 phases queries that specify 'Sort By' on 'Series limit' (#4203) --- superset/connectors/druid/models.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/superset/connectors/druid/models.py b/superset/connectors/druid/models.py index ff3251a27628a..57038097b7d11 100644 --- a/superset/connectors/druid/models.py +++ b/superset/connectors/druid/models.py @@ -1117,12 +1117,13 @@ def run_query( # noqa / druid ): dim = list(qry.get('dimensions'))[0] logging.info('Running two-phase topn query for dimension [{}]'.format(dim)) + pre_qry = deepcopy(qry) if timeseries_limit_metric: order_by = timeseries_limit_metric + pre_qry['aggregations'] = self.get_aggregations([timeseries_limit_metric]) else: order_by = list(qry['aggregations'].keys())[0] # Limit on the number of timeseries, doing a two-phases query - pre_qry = deepcopy(qry) pre_qry['granularity'] = 'all' pre_qry['threshold'] = min(row_limit, timeseries_limit or row_limit)