Skip to content
5 changes: 5 additions & 0 deletions caravel/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -1410,9 +1410,14 @@ def get_filters(raw_filters):
if len(splitted) > 1:
for s in eq.split(','):
s = s.strip()
if s == 'NULL':
s = None
fields.append(Dimension(col) == s)
cond = Filter(type="or", fields=fields)
else:
#allows setting filter to query that value of dimension is NULL
if eq == 'NULL':
eq = None
cond = Dimension(col) == eq
if op == 'not in':
cond = ~cond
Expand Down
2 changes: 1 addition & 1 deletion caravel/viz.py
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ def get_df(self, query_obj=None):
if self.datasource.offset:
df.timestamp += timedelta(hours=self.datasource.offset)
df.replace([np.inf, -np.inf], np.nan)
df = df.fillna(0)
df = df.fillna('NULL')

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

It seems like this main create some problems where there's missing data expected to be numeric. Ultimately we want javascript's reserved null in the json. Would df.fillna(None) work?

@kkalyan kkalyan Jul 29, 2016

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

df.fillna(None) threw an error 'must specify a fill method or value'
But I get your point - if ('NULL') is treated as true in javascript. we may need some similar handling in javascript (like value=='NULL'?value:null).

Side note - should this fillna be done only for Dimensions and skip Metrics ?

return df

@property
Expand Down