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

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


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

commit fcebb8046d002d19d9e271eeab4a8872383fd318
Author: Beto Dealmeida <robe...@dealmeida.net>
AuthorDate: Mon Apr 1 21:06:01 2019 -0700

    Fix race condition when fetching results in SQL Lab (#7198)
    
    * Fix race condition when fetching results in SQL Lab
    
    * Fix lint
---
 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 3fa3771..ad75c3b 100755
--- a/superset/views/core.py
+++ b/superset/views/core.py
@@ -2544,7 +2544,7 @@ class Superset(BaseSupersetView):
             database_id=int(database_id),
             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