villebro commented on a change in pull request #14507:
URL: https://github.com/apache/superset/pull/14507#discussion_r636029279



##########
File path: superset/jinja_context.py
##########
@@ -213,6 +176,142 @@ def url_param(
             self.cache_key_wrapper(result)
         return result
 
+    def filter_values(
+        self, column: str, default: Optional[str] = None, remove_filter: bool 
= False
+    ) -> List[str]:
+        """Gets a values for a particular filter as a list
+
+        This is useful if:
+            - you want to use a filter component to filter a query where the 
name of
+             filter component column doesn't match the one in the select 
statement
+            - you want to have the ability for filter inside the main query 
for speed
+            purposes
+
+        Usage example::
+
+            SELECT action, count(*) as times
+            FROM logs
+            WHERE
+                action in ({{ "'" + "','".join(filter_values('action_type')) + 
"'" }})
+            GROUP BY action
+
+        :param column: column/filter name to lookup
+        :param default: default value to return if there's no matching columns
+        :param remove_filter: When set to true, mark the filter as processed,
+            removing it from the outer query. Useful when a filter should
+            only apply to the inner query
+        :return: returns a list of filter values
+        """
+        return_val: List[str] = []
+        filters = self.get_filters(column, remove_filter)
+        for flt in filters:
+            val: Optional[Any] = flt.get("val")

Review comment:
       With additional typing this type annotation would be unnecessary




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
[email protected]



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to