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


##########
airflow/providers/snowflake/hooks/snowflake.py:
##########
@@ -305,15 +306,22 @@ def run(
             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.
+        :param split_statements: Whether to split a single SQL string into 
statements and run separately
+        :param return_last: Whether to return result for only last statement 
or for all after split
+        :return: return only result of the LAST SQL expression if handler was 
provided.
         """
         self.query_ids = []
 
+        scalar_return_last = isinstance(sql, str) and return_last
         if isinstance(sql, str):
-            split_statements_tuple = split_statements(StringIO(sql))
-            sql = [sql_string for sql_string, _ in split_statements_tuple if 
sql_string]
+            if split_statements:
+                split_statements_tuple = 
util_text.split_statements(StringIO(sql))
+                sql = [sql_string for sql_string, _ in split_statements_tuple 
if sql_string]
+            else:
+                sql = [sql]

Review Comment:
   All other hooks use `split_statements` from the DbApiHook except Snowflake. 
It has its own splitter and I'm not sure that `sqlparse.split` and 
`snowflake.connector.util_text.split_statements` behave similarly.
   Also, they will provide new splitting conditions in a new version of the 
library, so it forced me to keep it in Snowflake hook



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

Reply via email to