superset-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From maximebeauche...@apache.org
Subject [incubator-superset] branch master updated: [druid] fix bug around handling NULLs (#4358)
Date Wed, 07 Feb 2018 16:19:50 GMT
This is an automated email from the ASF dual-hosted git repository.

maximebeauchemin pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-superset.git


The following commit(s) were added to refs/heads/master by this push:
     new 31a0b6e  [druid] fix bug around handling NULLs (#4358)
31a0b6e is described below

commit 31a0b6e5b0b83bb6852f52bacd4f20b1fc09eacd
Author: Maxime Beauchemin <maximebeauchemin@gmail.com>
AuthorDate: Wed Feb 7 08:19:48 2018 -0800

    [druid] fix bug around handling NULLs (#4358)
    
    fillna would miss out on identifying STRING columns for Druid and
    replace None in string columns with a numeric `0`. This
    mixed type column would confuse
    pandas down the line on some operations like `df.pivot_table`.
---
 superset/viz.py | 13 ++++++++-----
 1 file changed, 8 insertions(+), 5 deletions(-)

diff --git a/superset/viz.py b/superset/viz.py
index 6fc8cf9..c500276 100644
--- a/superset/viz.py
+++ b/superset/viz.py
@@ -68,10 +68,10 @@ class BaseViz(object):
         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
 
@@ -79,8 +79,11 @@ class BaseViz(object):
         """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):

-- 
To stop receiving notification emails like this one, please contact
maximebeauchemin@apache.org.

Mime
View raw message