kazanzhy commented on code in PR #23971:
URL: https://github.com/apache/airflow/pull/23971#discussion_r926066450
##########
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:
I thought about the one additional parameter for this function, like:
```
def split_statements(sql, split_fn=None):
if split_fn:
return split_fn(sql)
else:
```
But it will add unnecessary complexity. We could leave
`snowflake.connector.util_text.split_statements` with TOD or use
`DbApiHook.split_statements` and hope that nothing won't be broken.
Probably I'll try to find some Snowflake queries and provide an experiment
--
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]