Skip to content

Commit

Permalink
Introduce class attr BaseViz.enforce_numerical_metrics (#5176)
Browse files Browse the repository at this point in the history
  • Loading branch information
mistercrunch authored Jun 14, 2018
1 parent 30111bf commit a109543
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion superset/viz.py
Original file line number Diff line number Diff line change
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

1 comment on commit a109543

@rzlmma
Copy link

@rzlmma rzlmma commented on a109543 Jun 15, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

agree with you

Please sign in to comment.