betodealmeida commented on a change in pull request #4651: [explore] proper 
filtering of NULLs and ''
URL: 
https://github.com/apache/incubator-superset/pull/4651#discussion_r181228300
 
 

 ##########
 File path: superset/connectors/druid/models.py
 ##########
 @@ -1322,40 +1339,30 @@ def increment_timestamp(ts):
             query=query_str,
             duration=datetime.now() - qry_start_dttm)
 
-    @staticmethod
-    def get_filters(raw_filters, num_cols):  # noqa
+    @classmethod
+    def get_filters(cls, raw_filters, num_cols):  # noqa
+        """Given Superset filter data structure, returns pydruid Filter(s)"""
         filters = None
         for flt in raw_filters:
-            if not all(f in flt for f in ['col', 'op', 'val']):
+            col = flt.get('col')
+            op = flt.get('op')
+            eq = flt.get('val')
+            if (
+                    not col or
+                    not op or
+                    (eq is None and op not in ('IS NULL', 'IS NOT NULL'))):
                 continue
-
-            col = flt['col']
-            op = flt['op']
-            eq = flt['val']
             cond = None
-            if op in ('in', 'not in'):
-                eq = [
-                    types.replace('"', '').strip()
-                    if isinstance(types, string_types)
-                    else types
-                    for types in eq]
-            elif not isinstance(flt['val'], string_types):
-                eq = eq[0] if eq and len(eq) > 0 else ''
-
             is_numeric_col = col in num_cols
-            if is_numeric_col:
-                if op in ('in', 'not in'):
-                    eq = [utils.string_to_num(v) for v in eq]
-                else:
-                    eq = utils.string_to_num(eq)
-
+            eq = cls.filter_values_handler(
+                eq, is_list_target=op in ('in', 'not in'),
 
 Review comment:
   This is a bit hard to read, can we define `is_list_target` outside the 
function call, like you did for `is_numeric_col`?

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services

Reply via email to