potiuk commented on code in PR #23971:
URL: https://github.com/apache/airflow/pull/23971#discussion_r922717511
##########
airflow/providers/common/sql/hooks/sql.py:
##########
@@ -232,22 +270,19 @@ def run(self, sql, autocommit=False, parameters=None,
handler=None):
results = []
for sql_statement in sql:
self._run_command(cur, sql_statement, parameters)
+
if handler is not None:
result = handler(cur)
results.append(result)
- # If autocommit was set to False for db that supports autocommit,
- # or if db does not supports autocommit, we do a manual commit.
+ # If autocommit was set to False or db does not support
autocommit, we do a manual commit.
if not self.get_autocommit(conn):
conn.commit()
if handler is None:
return None
-
- if scalar:
- return results[0]
-
- return results
+ else:
Review Comment:
I think this is backwards-incompatike. Currently when run gets a single SQL
string, it return s single result, if it gets array of strings it returns array
of results. In order to keep backwards compatibility we should retain this
behaviour.
I think the reasonable approach will be to check if even after split we have
one or multiple queries. If 1 -> return resullts[0] else results.
--
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]