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/11/05 07:24:43 UTC

[GitHub] [superset] villebro commented on a change in pull request #17287: fix(dashboard): Return columns and verbose_map for groupby values of Pivot Table v2 [ID-7]

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



##########
File path: superset/models/slice.py
##########
@@ -247,6 +247,17 @@ def form_data(self) -> Dict[str, Any]:
         update_time_range(form_data)
         return form_data
 
+    def get_query_context(self) -> Dict[str, Any]:
+        query_context: Dict[str, Any] = {}
+        if not self.query_context:
+            return query_context
+        try:
+            query_context = json.loads(self.query_context)
+        except json.decoder.JSONDecodeError as ex:
+            logger.error("Malformed json in slice's query context", exc_info=True)
+            logger.exception(ex)
+        return query_context
+

Review comment:
       @zhaoyongjie on the first return statement I believe we could instantiate the `QueryContext`. Also, for non v1 charts or in the case there isn't a query context payload, we probably should just return `None`, as the legacy charts aren't really compatible with `QueryContext`. Could this work?
   ```python
       def get_query_context(self) -> Optional[QueryContext]:
           if self.query_context:
               try:
                   return QueryContext(**json.loads(self.query_context))
               except json.decoder.JSONDecodeError as ex:
                   logger.error("Malformed json in slice's query context", exc_info=True)
                   logger.exception(ex)
           return None
   ```




-- 
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.

To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org

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