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 2021/01/27 00:46:47 UTC

[GitHub] [superset] graceguo-supercat commented on a change in pull request #12742: fix: Prevent dashboard with filter_values to cause incompatible indicator

graceguo-supercat commented on a change in pull request #12742:
URL: https://github.com/apache/superset/pull/12742#discussion_r564939146



##########
File path: superset/viz.py
##########
@@ -474,6 +475,18 @@ def get_payload(self, query_obj: Optional[QueryObjectDict] = None) -> VizPayload
         filters = self.form_data.get("filters", [])
         filter_columns = [flt.get("col") for flt in filters]
         columns = set(self.datasource.column_names)
+        filter_values_columns = []
+
+        # if using virtual datasource, check filter_values
+        sql = self.datasource.sql
+        if sql:
+            statements_without_comments = sqlparse.format(sql, strip_comments=True)
+            parsed_query = sql_parse.ParsedQuery(statements_without_comments)
+            for stmt in parsed_query.get_statements():
+                filter_values_columns += (
+                    re.findall(r"filter_values\(\"(\w+)\"\,", stmt)

Review comment:
       fixed.

##########
File path: superset/viz.py
##########
@@ -484,7 +497,7 @@ def get_payload(self, query_obj: Optional[QueryObjectDict] = None) -> VizPayload
         payload["rejected_filters"] = [
             {"reason": "not_in_datasource", "column": col}
             for col in filter_columns
-            if col not in columns
+            if col not in columns and col not in filter_values_columns

Review comment:
       fixed.

##########
File path: superset/viz.py
##########
@@ -474,6 +475,18 @@ def get_payload(self, query_obj: Optional[QueryObjectDict] = None) -> VizPayload
         filters = self.form_data.get("filters", [])
         filter_columns = [flt.get("col") for flt in filters]
         columns = set(self.datasource.column_names)
+        filter_values_columns = []
+
+        # if using virtual datasource, check filter_values
+        sql = self.datasource.sql

Review comment:
       fixed.




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



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