This is an automated email from the ASF dual-hosted git repository.

michellet pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-superset.git


The following commit(s) were added to refs/heads/master by this push:
     new 52473c5  Fix race condition when fetching results in SQL Lab (#7198) 
(#7242)
52473c5 is described below

commit 52473c5d34435dba45064416f8c5ca967cc4c064
Author: michellethomas <michelle.q.tho...@gmail.com>
AuthorDate: Mon Apr 8 15:08:32 2019 -0700

    Fix race condition when fetching results in SQL Lab (#7198) (#7242)
    
    * Fix race condition when fetching results in SQL Lab
    
    * Fix lint
    
    (cherry picked from commit ca6a73b028a1954c8e8d1dfa077bc7ee0a2694c0)
---
 superset/sql_lab.py    | 9 ++-------
 superset/views/core.py | 2 +-
 2 files changed, 3 insertions(+), 8 deletions(-)

diff --git a/superset/sql_lab.py b/superset/sql_lab.py
index a02a758..6a5ee8e 100644
--- a/superset/sql_lab.py
+++ b/superset/sql_lab.py
@@ -141,9 +141,7 @@ def get_sql_results(
             return handle_query_error(str(e), query, session)
 
 
-def execute_sql_statement(
-        sql_statement, query, user_name, session,
-        cursor, return_results=False):
+def execute_sql_statement(sql_statement, query, user_name, session, cursor):
     """Executes a single SQL statement"""
     database = query.database
     db_engine_spec = database.db_engine_spec
@@ -256,11 +254,9 @@ def execute_sql_statements(
                 logging.info(msg)
                 query.set_extra_json_key('progress', msg)
                 session.commit()
-                is_last_statement = i == len(statements) - 1
                 try:
                     cdf = execute_sql_statement(
-                        statement, query, user_name, session, cursor,
-                        return_results=is_last_statement and return_results)
+                        statement, query, user_name, session, cursor)
                     msg = f'Running statement {i+1} out of {statement_count}'
                 except Exception as e:
                     msg = str(e)
@@ -282,7 +278,6 @@ def execute_sql_statements(
             show_cols=False,
             latest_partition=False)
     query.end_time = now_as_float()
-    session.commit()
 
     payload.update({
         'status': query.status,
diff --git a/superset/views/core.py b/superset/views/core.py
index ad5153b..d52bebe 100755
--- a/superset/views/core.py
+++ b/superset/views/core.py
@@ -2564,7 +2564,7 @@ class Superset(BaseSupersetView):
             limit=min(lim for lim in limits if lim is not None),
             sql=sql,
             schema=schema,
-            select_as_cta=request.form.get('select_as_cta') == 'true',
+            select_as_cta=select_as_cta,
             start_time=now_as_float(),
             tab_name=request.form.get('tab'),
             status=QueryStatus.PENDING if async_ else QueryStatus.RUNNING,

Reply via email to