You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@superset.apache.org by GitBox <gi...@apache.org> on 2018/05/07 22:29:30 UTC

[GitHub] john-bodley commented on a change in pull request #4909: [Explore] Adding Adhoc Filters

john-bodley commented on a change in pull request #4909: [Explore] Adding Adhoc Filters
URL: https://github.com/apache/incubator-superset/pull/4909#discussion_r186568950
 
 

 ##########
 File path: superset/viz.py
 ##########
 @@ -252,14 +252,68 @@ def query_obj(self):
 
         # extras are used to query elements specific to a datasource type
         # for instance the extra where clause that applies only to Tables
-        extras = {
-            'where': form_data.get('where', ''),
-            'having': form_data.get('having', ''),
-            'having_druid': form_data.get('having_filters', []),
-            'time_grain_sqla': form_data.get('time_grain_sqla', ''),
-            'druid_time_origin': form_data.get('druid_time_origin', ''),
-        }
-        filters = form_data.get('filters', [])
+
+        extras = {}
+        filters = []
+        adhoc_filters = form_data.get('adhoc_filters', None)
+        if adhoc_filters is None:
+            extras = {
+                'where': form_data.get('where', ''),
+                'having': form_data.get('having', ''),
+                'having_druid': form_data.get('having_filters', []),
+                'time_grain_sqla': form_data.get('time_grain_sqla', ''),
+                'druid_time_origin': form_data.get('druid_time_origin', ''),
+            }
+            filters = form_data.get('filters', [])
+        elif isinstance(adhoc_filters, list):
+            simple_where_filters = []
+            simple_having_filters = []
+            sql_where_filters = []
+            sql_having_filters = []
+            for adhoc_filter in adhoc_filters:
+                expression_type = adhoc_filter.get('expressionType')
+                clause = adhoc_filter.get('clause')
+                if expression_type == 'SIMPLE':
+                    if clause == 'WHERE':
+                        simple_where_filters.append({
+                            'col': adhoc_filter.get('subject'),
+                            'op': adhoc_filter.get('operator'),
+                            'val': adhoc_filter.get('comparator'),
+                        })
+                    if clause == 'HAVING':
 
 Review comment:
   Nit. `s/if/elif`.

----------------------------------------------------------------
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:
users@infra.apache.org


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org