You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@superset.apache.org by jo...@apache.org on 2019/01/11 02:22:38 UTC
[incubator-superset] 34/43: fixed test
This is an automated email from the ASF dual-hosted git repository.
johnbodley pushed a commit to branch feature--embeddable-charts-pilot
in repository https://gitbox.apache.org/repos/asf/incubator-superset.git
commit 45a4a76f3f7809f0667c5933a4fc6e24ad5f6aed
Author: Conglei Shi <co...@airbnb.com>
AuthorDate: Fri Dec 14 17:32:46 2018 -0800
fixed test
---
superset/connectors/druid/models.py | 9 +++++----
superset/viz.py | 25 +++++++++++++------------
2 files changed, 18 insertions(+), 16 deletions(-)
diff --git a/superset/connectors/druid/models.py b/superset/connectors/druid/models.py
index ae53246..10baa84 100644
--- a/superset/connectors/druid/models.py
+++ b/superset/connectors/druid/models.py
@@ -893,10 +893,10 @@ class DruidDatasource(Model, BaseDatasource):
for metric in metrics:
if utils.is_adhoc_metric(metric):
adhoc_agg_configs.append(metric)
- elif metrics_dict[metric].metric_type != POST_AGG_TYPE:
- saved_agg_names.add(metric)
+ elif metrics_dict[metric['label']].metric_type != POST_AGG_TYPE:
+ saved_agg_names.add(metric['label'])
else:
- postagg_names.append(metric)
+ postagg_names.append(metric['label'])
# Create the post aggregations, maintain order since postaggs
# may depend on previous ones
post_aggs = OrderedDict()
@@ -1371,7 +1371,8 @@ class DruidDatasource(Model, BaseDatasource):
cols += [DTTM_ALIAS]
cols += query_obj.get('groupby') or []
cols += query_obj.get('columns') or []
- cols += query_obj.get('metrics') or []
+ metrics = query_obj.get('metrics') or []
+ cols += [metric['label'] for metric in metrics]
cols = utils.get_metric_names(cols)
cols = [col for col in cols if col in df.columns]
diff --git a/superset/viz.py b/superset/viz.py
index ed6f43b..6c0a5f5 100644
--- a/superset/viz.py
+++ b/superset/viz.py
@@ -253,18 +253,19 @@ class BaseViz(object):
def query_obj(self):
query_obj = self._query_obj()
- metrics = query_obj.get('metrics')
- formatted_metrics = []
- for metric in metrics:
- if not isinstance(metric, dict):
- metric = {
- 'label': metric,
- 'expressionType': 'BUILTIN',
- }
- formatted_metrics.append(metric)
- query_obj.update({
- 'metrics': formatted_metrics,
- })
+ if (query_obj):
+ metrics = query_obj.get('metrics', [])
+ formatted_metrics = []
+ for metric in metrics:
+ if not isinstance(metric, dict):
+ metric = {
+ 'label': metric,
+ 'expressionType': 'BUILTIN',
+ }
+ formatted_metrics.append(metric)
+ query_obj.update({
+ 'metrics': formatted_metrics,
+ })
return query_obj
def _query_obj(self):