jeffreythewang commented on a change in pull request #4646: Allowing limit
ordering by post-aggregation metrics
URL:
https://github.com/apache/incubator-superset/pull/4646#discussion_r175866052
##########
File path: superset/connectors/druid/models.py
##########
@@ -1134,7 +1137,11 @@ def run_query( # noqa / druid
pre_qry = deepcopy(qry)
if timeseries_limit_metric:
order_by = timeseries_limit_metric
- pre_qry['aggregations'] =
self.get_aggregations([timeseries_limit_metric])
+ aggs_dict, post_aggs_dict = DruidDatasource.aggs_and_post_aggs(
+ [timeseries_limit_metric],
+ metrics_dict)
+ pre_qry['aggregations'].update(aggs_dict)
Review comment:
For two-phase queries, replacement is fine since the `pre_qry`s only purpose
is to query for the top N groups. For single-phase queries, the `pre_qry` is
the only query that runs, so the existing metrics that are queried for must be
preserved as well.
I've written a few test scenarios for this.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services