You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@superset.apache.org by GitBox <gi...@apache.org> on 2018/08/14 05:33:30 UTC

[GitHub] mistercrunch closed pull request #5597: No exception on no data

mistercrunch closed pull request #5597: No exception on no data
URL: https://github.com/apache/incubator-superset/pull/5597
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git a/superset/connectors/druid/models.py b/superset/connectors/druid/models.py
index 0554dfab31..824d7c9ee4 100644
--- a/superset/connectors/druid/models.py
+++ b/superset/connectors/druid/models.py
@@ -20,6 +20,7 @@
 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 @@ def query(self, query_obj):
         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 f3b18f8d31..f5a79032ea 100644
--- a/superset/models/core.py
+++ b/superset/models/core.py
@@ -793,9 +793,14 @@ def needs_conversion(df_series):
 
                 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 b0a71d5a9d..c295e5a88a 100644
--- a/superset/viz.py
+++ b/superset/viz.py
@@ -179,7 +179,6 @@ def get_df(self, query_obj=None):
             return None
 
         self.error_msg = ''
-        self.results = None
 
         timestamp_format = None
         if self.datasource.type == 'table':


 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org