superset-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From maximebeauche...@apache.org
Subject [incubator-superset] branch master updated: Handle Time at query_obj generation time (#3236)
Date Thu, 03 Aug 2017 22:42:31 GMT
This is an automated email from the ASF dual-hosted git repository.

maximebeauchemin pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-superset.git


The following commit(s) were added to refs/heads/master by this push:
     new 4c3313b  Handle Time at query_obj generation time (#3236)
4c3313b is described below

commit 4c3313b01cb508ced8519a68f6479db423974929
Author: Maxime Beauchemin <maximebeauchemin@gmail.com>
AuthorDate: Thu Aug 3 15:42:26 2017 -0700

    Handle Time at query_obj generation time (#3236)
    
    As opposed to in the within itself
---
 superset/connectors/druid/models.py |  4 ----
 superset/connectors/sqla/models.py  |  4 ----
 superset/viz.py                     | 21 +++++++++++++--------
 3 files changed, 13 insertions(+), 16 deletions(-)

diff --git a/superset/connectors/druid/models.py b/superset/connectors/druid/models.py
index 53aeb5a..335f9d2 100644
--- a/superset/connectors/druid/models.py
+++ b/superset/connectors/druid/models.py
@@ -818,10 +818,6 @@ class DruidDatasource(Model, BaseDatasource):
         # TODO refactor into using a TBD Query object
         client = client or self.cluster.get_pydruid_client()
 
-        if DTTM_ALIAS in groupby:
-            groupby.remove(DTTM_ALIAS)
-            is_timeseries = True
-
         if not is_timeseries:
             granularity = 'all'
         inner_from_dttm = inner_from_dttm or from_dttm
diff --git a/superset/connectors/sqla/models.py b/superset/connectors/sqla/models.py
index 6759d2c..b836a15 100644
--- a/superset/connectors/sqla/models.py
+++ b/superset/connectors/sqla/models.py
@@ -376,10 +376,6 @@ class SqlaTable(Model, BaseDatasource):
         template_processor = self.get_template_processor(**template_kwargs)
         db_engine_spec = self.database.db_engine_spec
 
-        if DTTM_ALIAS in groupby:
-            groupby.remove(DTTM_ALIAS)
-            is_timeseries = True
-
         # For backward compatibility
         if granularity not in self.dttm_cols:
             granularity = self.main_dttm_col
diff --git a/superset/viz.py b/superset/viz.py
index de1f635..942c670 100755
--- a/superset/viz.py
+++ b/superset/viz.py
@@ -114,6 +114,13 @@ class BaseViz(object):
         form_data = self.form_data
         groupby = form_data.get("groupby") or []
         metrics = form_data.get("metrics") or []
+        columns = form_data.get("columns") or []
+        groupby = list(set(groupby + columns))
+
+        is_timeseries = self.is_timeseries
+        if DTTM_ALIAS in groupby:
+            groupby.remove(DTTM_ALIAS)
+            is_timeseries = True
 
         # extra_filters are temporary/contextual filters that are external
         # to the slice definition. We use those for dynamic interactive
@@ -173,7 +180,7 @@ class BaseViz(object):
             'granularity': granularity,
             'from_dttm': from_dttm,
             'to_dttm': to_dttm,
-            'is_timeseries': self.is_timeseries,
+            'is_timeseries': is_timeseries,
             'groupby': groupby,
             'metrics': metrics,
             'row_limit': row_limit,
@@ -385,9 +392,7 @@ class PivotTableViz(BaseViz):
         if (
                 any(v in groupby for v in columns) or
                 any(v in columns for v in groupby)):
-            raise Exception("groupby and columns can't overlap")
-
-        d['groupby'] = list(set(groupby) | set(columns))
+            raise Exception(""""Group By" and "Columns" can't overlap""")
         return d
 
     def get_data(self, df):
@@ -1082,10 +1087,10 @@ class DistributionBarViz(DistributionPieViz):
     def query_obj(self):
         d = super(DistributionBarViz, self).query_obj()  # noqa
         fd = self.form_data
-        gb = fd.get('groupby') or []
-        cols = fd.get('columns') or []
-        d['groupby'] = set(gb + cols)
-        if len(d['groupby']) < len(gb) + len(cols):
+        if (
+                len(self.groupby) <
+                len(fd.get('groupby') or []) + len(fd.get('columns') or [])
+                ):
             raise Exception("Can't have overlap between Series and Breakdowns")
         if not self.metrics:
             raise Exception("Pick at least one metric")

-- 
To stop receiving notification emails like this one, please contact
['"commits@superset.apache.org" <commits@superset.apache.org>'].

Mime
View raw message