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

[druid] fix bug around handling NULLs #4358

Merged
merged 1 commit into from
Feb 7, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 8 additions & 5 deletions superset/viz.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,19 +68,22 @@ def __init__(self, datasource, form_data):
self.status = None
self.error_message = None

def get_fillna_for_type(self, col_type):
def get_fillna_for_col(self, col):
"""Returns the value for use as filler for a specific Column.type"""
if col_type:
if col_type == 'TEXT' or col_type.startswith('VARCHAR'):
if col:
if col.is_string:
return ' NULL'
return self.default_fillna

def get_fillna_for_columns(self, columns=None):
"""Returns a dict or scalar that can be passed to DataFrame.fillna"""
if columns is None:
return self.default_fillna
columns_types = self.datasource.columns_types
fillna = {c: self.get_fillna_for_type(columns_types.get(c)) for c in columns}
columns_dict = {col.column_name: col for col in self.datasource.columns}
fillna = {
c: self.get_fillna_for_col(columns_dict.get(c))
for c in columns
}
return fillna

def get_df(self, query_obj=None):
Expand Down