john-bodley commented on a change in pull request #4834: Load async sql lab 
results early for Presto
URL: 
https://github.com/apache/incubator-superset/pull/4834#discussion_r183946690
 
 

 ##########
 File path: superset/db_engine_specs.py
 ##########
 @@ -639,7 +641,28 @@ def extra_table_metadata(cls, database, table_name, 
schema_name):
         }
 
     @classmethod
-    def handle_cursor(cls, cursor, query, session):
+    def prefetch_results(cls, cursor, query, cache_timeout, session, 
limit=1000):
+        data = cursor.fetchmany(limit)
+        cdf = utils.convert_results_to_df(cursor.description, data)
+        payload = dict(query_id=query.id)
+        payload.update({
+            'status': utils.QueryStatus.PREFETCHED,
+            'data': cdf.data if cdf.data else [],
+            'columns': cdf.columns if cdf.columns else [],
+            'query': query.to_dict(),
+        })
+
+        json_payload = json.dumps(payload, default=utils.json_iso_dttm_ser)
+        key = '{}'.format(uuid.uuid4())
+        prefetch_key = key + '_prefetch'
 
 Review comment:
   I'm not certain the structure of other keys, but given this is a UUID and 
thus unique I'm not sure whether you need to add the `_prefix` suffix.

----------------------------------------------------------------
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:
[email protected]


With regards,
Apache Git Services

Reply via email to