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: No exception on no data (#5597)
Date Tue, 14 Aug 2018 05:33: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 763eeca  No exception on no data (#5597)
763eeca is described below

commit 763eeca75a8243fb5397debecc31e360732de3ea
Author: Beto Dealmeida <roberto@dealmeida.net>
AuthorDate: Mon Aug 13 22:33:29 2018 -0700

    No exception on no data (#5597)
    
    * No exception on no data
    
    * Remove unreachable exception
---
 superset/connectors/druid/models.py | 6 +++++-
 superset/models/core.py             | 7 ++++++-
 superset/viz.py                     | 1 -
 3 files changed, 11 insertions(+), 3 deletions(-)

diff --git a/superset/connectors/druid/models.py b/superset/connectors/druid/models.py
index 0554dfa..824d7c9 100644
--- a/superset/connectors/druid/models.py
+++ b/superset/connectors/druid/models.py
@@ -20,6 +20,7 @@ from flask import escape, Markup
 from flask_appbuilder import Model
 from flask_appbuilder.models.decorators import renders
 from flask_babel import lazy_gettext as _
+import pandas
 from pydruid.client import PyDruid
 from pydruid.utils.aggregators import count
 from pydruid.utils.dimensions import MapLookupExtraction, RegexExtraction
@@ -1346,7 +1347,10 @@ class DruidDatasource(Model, BaseDatasource):
         df = client.export_pandas()
 
         if df is None or df.size == 0:
-            raise Exception(_('No data was returned.'))
+            return QueryResult(
+                df=pandas.DataFrame([]),
+                query=query_str,
+                duration=datetime.now() - qry_start_dttm)
 
         df = self.homogenize_types(df, query_obj.get('groupby', []))
         df.columns = [
diff --git a/superset/models/core.py b/superset/models/core.py
index 05db09f..50f657c 100644
--- a/superset/models/core.py
+++ b/superset/models/core.py
@@ -794,9 +794,14 @@ class Database(Model, AuditMixinNullable, ImportMixin):
 
                 self.db_engine_spec.execute(cursor, sqls[-1])
 
+                if cursor.description is not None:
+                    columns = [col_desc[0] for col_desc in cursor.description]
+                else:
+                    columns = []
+
                 df = pd.DataFrame.from_records(
                     data=list(cursor.fetchall()),
-                    columns=[col_desc[0] for col_desc in cursor.description],
+                    columns=columns,
                     coerce_float=True,
                 )
 
diff --git a/superset/viz.py b/superset/viz.py
index b0a71d5..c295e5a 100644
--- a/superset/viz.py
+++ b/superset/viz.py
@@ -179,7 +179,6 @@ class BaseViz(object):
             return None
 
         self.error_msg = ''
-        self.results = None
 
         timestamp_format = None
         if self.datasource.type == 'table':


Mime
View raw message