You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by GitBox <gi...@apache.org> on 2021/09/05 09:19:28 UTC

[GitHub] [airflow] uranusjr commented on a change in pull request #17329: Split sql statements in DbApi run

uranusjr commented on a change in pull request #17329:
URL: https://github.com/apache/airflow/pull/17329#discussion_r702394237



##########
File path: airflow/hooks/dbapi.py
##########
@@ -190,18 +191,28 @@ def run(self, sql, autocommit=False, parameters=None, handler=None):
         :param handler: The result handler which is called with the result of each statement.
         :type handler: callable
         :return: query results if handler was provided.
+        :param split_statements: If true, split sql statements
+        :type split_statements: bool
         """
         scalar = isinstance(sql, str)
         if scalar:
             sql = [sql]
+        sql_statements = sql
+
+        if split_statements:
+            sql_statements = []
+            for q in sql:
+                sql_statements.extend(
+                    [s.rstrip(";") for s in sqlparse.split(sqlparse.format(q, strip_comments=True))]
+                )

Review comment:
       ```suggestion
               sql_statements = [
               	s
                   for q in sql
                   for s in sqlparse.split(sqlparse.format(q, strip_comments=True))
               ]
   ```




-- 
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: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org