From 1b330a8c55f0ec114970855c6682627434216ab5 Mon Sep 17 00:00:00 2001 From: Bogdan Date: Wed, 15 Mar 2017 18:13:15 -0700 Subject: [PATCH] Use connector registry for metrics (#2420) --- superset/views/core.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/superset/views/core.py b/superset/views/core.py index 1b5f008419cd0..ad8ce14286fa2 100755 --- a/superset/views/core.py +++ b/superset/views/core.py @@ -1794,6 +1794,7 @@ def sqllab_viz(self): is_dim = config.get('is_dim', False) SqlaTable = ConnectorRegistry.sources['table'] TableColumn = SqlaTable.column_cls + SqlMetric = SqlaTable.metric_cls col = TableColumn( column_name=column_name, filterable=is_dim, @@ -1806,18 +1807,18 @@ def sqllab_viz(self): agg = config.get('agg') if agg: if agg == 'count_distinct': - metrics.append(models.SqlMetric( + metrics.append(SqlMetric( metric_name="{agg}__{column_name}".format(**locals()), expression="COUNT(DISTINCT {column_name})" .format(**locals()), )) else: - metrics.append(models.SqlMetric( + metrics.append(SqlMetric( metric_name="{agg}__{column_name}".format(**locals()), expression="{agg}({column_name})".format(**locals()), )) if not metrics: - metrics.append(models.SqlMetric( + metrics.append(SqlMetric( metric_name="count".format(**locals()), expression="count(*)".format(**locals()), ))