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 2022/07/14 12:21:13 UTC

[GitHub] [airflow] potiuk commented on a diff in pull request #23971: Unify DbApiHook.run() method with the methods which override it

potiuk commented on code in PR #23971:
URL: https://github.com/apache/airflow/pull/23971#discussion_r921092159


##########
airflow/providers/common/sql/hooks/sql.py:
##########
@@ -213,14 +243,13 @@ def run(self, sql, autocommit=False, parameters=None, handler=None):
             before executing the query.
         :param parameters: The parameters to render the SQL query with.
         :param handler: The result handler which is called with the result of each statement.
-        :return: query results if handler was provided.
+        :return: return only result of the LAST SQL expression if handler was provided.
         """
-        scalar = isinstance(sql, str)
-        if scalar:
-            sql = [sql]
+        if isinstance(sql, str):
+            sql = self.maybe_split_sql_string(sql)

Review Comment:
   Fully agree with elad here. 



##########
airflow/providers/common/sql/hooks/sql.py:
##########
@@ -213,14 +243,13 @@ def run(self, sql, autocommit=False, parameters=None, handler=None):
             before executing the query.
         :param parameters: The parameters to render the SQL query with.
         :param handler: The result handler which is called with the result of each statement.
-        :return: query results if handler was provided.
+        :return: return only result of the LAST SQL expression if handler was provided.
         """
-        scalar = isinstance(sql, str)
-        if scalar:
-            sql = [sql]
+        if isinstance(sql, str):
+            sql = self.maybe_split_sql_string(sql)

Review Comment:
   Fully agree with @eladkal  here. 



-- 
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