Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Introduce class attr BaseViz.enforce_numerical_metrics #5176

Merged
merged 1 commit into from Jun 14, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 4 additions & 1 deletion superset/viz.py
Expand Up @@ -59,6 +59,7 @@ class BaseViz(object):
is_timeseries = False
default_fillna = 0
cache_type = 'df'
enforce_numerical_metrics = True

def __init__(self, datasource, form_data, force=False):
if not datasource:
Expand Down Expand Up @@ -209,7 +210,8 @@ def get_df(self, query_obj=None):
df[DTTM_ALIAS] += timedelta(hours=self.datasource.offset)
df[DTTM_ALIAS] += self.time_shift

self.df_metrics_to_num(df, query_obj.get('metrics') or [])
if self.enforce_numerical_metrics:
self.df_metrics_to_num(df, query_obj.get('metrics') or [])

df.replace([np.inf, -np.inf], np.nan)
self.handle_nulls(df)
Expand Down Expand Up @@ -483,6 +485,7 @@ class TableViz(BaseViz):
verbose_name = _('Table View')
credits = 'a <a href="https://github.com/airbnb/superset">Superset</a> original'
is_timeseries = False
enforce_numerical_metrics = False

def should_be_timeseries(self):
fd = self.form_data
Expand Down