jeffreythewang commented on a change in pull request #4646: [BugFix] 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.
This situation may not be as obvious since the Table View (in my experience,
the view most frequently used for single-phase queries) rarely uses the Sort By
field and instead just sorts via the Table UI. I've written a few tests for the
scenarios where single-phase queries run with an order and limit specified.
----------------------------------------------------------------
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