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 2022/05/16 21:43:19 UTC

[GitHub] [superset] AAfghahi commented on a diff in pull request #20059: feat: Save column data into json_metadata for all Query executions

AAfghahi commented on code in PR #20059:
URL: https://github.com/apache/superset/pull/20059#discussion_r874182780


##########
superset/queries/dao.py:
##########
@@ -48,3 +50,20 @@ def update_saved_query_exec_info(query_id: int) -> None:
                 saved_query.rows = query.rows
                 saved_query.last_run = datetime.now()
             db.session.commit()
+
+    @staticmethod
+    def save_metadata(query: Query, query_payload: str) -> None:
+        # parse payload
+        try:
+            payload: Dict[str, Any] = json.loads(query_payload)
+        except json.JSONDecodeError:
+            logger.warning("Error parsing query_payload: %s", query_payload)
+            return None
+
+        # pull relevant data from payload and store in json_metadata
+        columns = payload.get("columns", {})
+
+        # save payload into query object
+        db.session.add(query)
+        query.set_extra_json_key("columns", columns)
+        return None

Review Comment:
   why do these have return statement? 



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