You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@superset.apache.org by ma...@apache.org on 2017/11/17 06:41:58 UTC

[incubator-superset] branch master updated: [druid] Fix datasource column enumeration (#3896)

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 f0acc11  [druid] Fix datasource column enumeration (#3896)
f0acc11 is described below

commit f0acc11249f4e9e75af8112b0015e564cfe38511
Author: John Bodley <45...@users.noreply.github.com>
AuthorDate: Thu Nov 16 22:41:54 2017 -0800

    [druid] Fix datasource column enumeration (#3896)
---
 superset/connectors/druid/models.py | 61 +++++++++++++++++++------------------
 1 file changed, 31 insertions(+), 30 deletions(-)

diff --git a/superset/connectors/druid/models.py b/superset/connectors/druid/models.py
index 4c8a016..0d455f9 100644
--- a/superset/connectors/druid/models.py
+++ b/superset/connectors/druid/models.py
@@ -166,36 +166,37 @@ class DruidCluster(Model, AuditMixinNullable):
         for i in range(0, len(ds_refresh)):
             datasource = ds_refresh[i]
             cols = metadata[i]
-            col_objs_list = (
-                session.query(DruidColumn)
-                .filter(DruidColumn.datasource_name == datasource.datasource_name)
-                .filter(or_(DruidColumn.column_name == col for col in cols))
-            )
-            col_objs = {col.column_name: col for col in col_objs_list}
-            for col in cols:
-                if col == '__time':  # skip the time column
-                    continue
-                col_obj = col_objs.get(col, None)
-                if not col_obj:
-                    col_obj = DruidColumn(
-                        datasource_name=datasource.datasource_name,
-                        column_name=col)
-                    with session.no_autoflush:
-                        session.add(col_obj)
-                datatype = cols[col]['type']
-                if datatype == 'STRING':
-                    col_obj.groupby = True
-                    col_obj.filterable = True
-                if datatype == 'hyperUnique' or datatype == 'thetaSketch':
-                    col_obj.count_distinct = True
-                # Allow sum/min/max for long or double
-                if datatype == 'LONG' or datatype == 'DOUBLE':
-                    col_obj.sum = True
-                    col_obj.min = True
-                    col_obj.max = True
-                col_obj.type = datatype
-                col_obj.datasource = datasource
-            datasource.generate_metrics_for(col_objs_list)
+            if cols:
+                col_objs_list = (
+                    session.query(DruidColumn)
+                    .filter(DruidColumn.datasource_name == datasource.datasource_name)
+                    .filter(or_(DruidColumn.column_name == col for col in cols))
+                )
+                col_objs = {col.column_name: col for col in col_objs_list}
+                for col in cols:
+                    if col == '__time':  # skip the time column
+                        continue
+                    col_obj = col_objs.get(col, None)
+                    if not col_obj:
+                        col_obj = DruidColumn(
+                            datasource_name=datasource.datasource_name,
+                            column_name=col)
+                        with session.no_autoflush:
+                            session.add(col_obj)
+                    datatype = cols[col]['type']
+                    if datatype == 'STRING':
+                        col_obj.groupby = True
+                        col_obj.filterable = True
+                    if datatype == 'hyperUnique' or datatype == 'thetaSketch':
+                        col_obj.count_distinct = True
+                    # Allow sum/min/max for long or double
+                    if datatype == 'LONG' or datatype == 'DOUBLE':
+                        col_obj.sum = True
+                        col_obj.min = True
+                        col_obj.max = True
+                    col_obj.type = datatype
+                    col_obj.datasource = datasource
+                datasource.generate_metrics_for(col_objs_list)
         session.commit()
 
     @property

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