mirror of
https://github.com/apache/superset.git
synced 2024-09-12 08:39:45 -04:00
No exception on no data (#5597)
* No exception on no data * Remove unreachable exception
This commit is contained in:
parent
5c1d906976
commit
763eeca75a
@ -20,6 +20,7 @@ from flask import escape, Markup
|
|||||||
from flask_appbuilder import Model
|
from flask_appbuilder import Model
|
||||||
from flask_appbuilder.models.decorators import renders
|
from flask_appbuilder.models.decorators import renders
|
||||||
from flask_babel import lazy_gettext as _
|
from flask_babel import lazy_gettext as _
|
||||||
|
import pandas
|
||||||
from pydruid.client import PyDruid
|
from pydruid.client import PyDruid
|
||||||
from pydruid.utils.aggregators import count
|
from pydruid.utils.aggregators import count
|
||||||
from pydruid.utils.dimensions import MapLookupExtraction, RegexExtraction
|
from pydruid.utils.dimensions import MapLookupExtraction, RegexExtraction
|
||||||
@ -1346,7 +1347,10 @@ class DruidDatasource(Model, BaseDatasource):
|
|||||||
df = client.export_pandas()
|
df = client.export_pandas()
|
||||||
|
|
||||||
if df is None or df.size == 0:
|
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 = self.homogenize_types(df, query_obj.get('groupby', []))
|
||||||
df.columns = [
|
df.columns = [
|
||||||
|
@ -794,9 +794,14 @@ class Database(Model, AuditMixinNullable, ImportMixin):
|
|||||||
|
|
||||||
self.db_engine_spec.execute(cursor, sqls[-1])
|
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(
|
df = pd.DataFrame.from_records(
|
||||||
data=list(cursor.fetchall()),
|
data=list(cursor.fetchall()),
|
||||||
columns=[col_desc[0] for col_desc in cursor.description],
|
columns=columns,
|
||||||
coerce_float=True,
|
coerce_float=True,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -179,7 +179,6 @@ class BaseViz(object):
|
|||||||
return None
|
return None
|
||||||
|
|
||||||
self.error_msg = ''
|
self.error_msg = ''
|
||||||
self.results = None
|
|
||||||
|
|
||||||
timestamp_format = None
|
timestamp_format = None
|
||||||
if self.datasource.type == 'table':
|
if self.datasource.type == 'table':
|
||||||
|
Loading…
Reference in New Issue
Block a user