cBrayton commented on code in PR #27548:
URL: https://github.com/apache/airflow/pull/27548#discussion_r1018205747


##########
airflow/providers/common/sql/hooks/sql.py:
##########
@@ -273,7 +273,7 @@ def run(
             if not self.get_autocommit(conn):
                 conn.commit()
 
-        if handler is None:
+        if handler is not None:

Review Comment:
   The run function for all of these hooks is used to run one or more SQL 
commands. There is an optional parameter to pass the results from the SQL 
commands to a handler. The handler can be any callable function, but the 
default value for the optional parameter is None.
   
   If a handler is provided, the results are passed to the handler, processed 
by the handler, and the run function returns the results.
   
   If a handler is not provided (handler = None), the run function returns 
None. This is because the line `if handler is None` is True forcing the run 
function to return None.
   
   My change flips these two scenarios for the run function. (Proposed flow 
below:)
   If the handler is provided, (after the results are passed to and processed 
by the handler) the run function returns None. (The results have been processed 
elsewhere, run doesn't need to return them.)
   If the handler is not provided (handler = None), the run function returns 
the results of the SQL commands.



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