uranusjr commented on a change in pull request #17329:
URL: https://github.com/apache/airflow/pull/17329#discussion_r685059467
##########
File path: airflow/hooks/dbapi.py
##########
@@ -176,18 +177,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:
I think we need to also set `scalar = False` here? Otherwise only the
last statement’s result can be returned, which seems unintuitive to me.
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]