potiuk commented on code in PR #27912:
URL: https://github.com/apache/airflow/pull/27912#discussion_r1032651745
##########
airflow/providers/common/sql/hooks/sql.py:
##########
@@ -234,7 +266,42 @@ def run(
"""
Runs a command or a list of commands. Pass a list of sql
statements to the sql parameter to get them to execute
- sequentially
+ sequentially.
+
+ The method will return either single query results (typically list of
rows) or list of those results
+ where each element in the list are results of one of the queries
(typically list of list of rows :D)
+
+ For compatibility reasons, the behaviour of the DBAPIHook is somewhat
confusing.
+ In cases, when multiple queries are run, the return values will be an
iterable (list) of results
+ - one for each query. However, in certain cases, when single query is
run - the results will be just
+ the results of that query without wrapping the results in a list.
+
+ The cases when single query results are returned without wrapping them
in a list are when:
+
+ a) sql is string and last_statement is True (regardless what
split_statement value is)
+ b) sql is string and split_statement is False
+
+ In all other cases, the results are wrapped in a list, even if there
is only one statement to process:
+
+ a) always when sql is iterable (regardless what last_statement value
is)
+ b) when sql is string, split_statement is True and last_statement is
False
Review Comment:
Fixed
--
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]