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


##########
airflow/providers/common/sql/hooks/sql.py:
##########
@@ -294,6 +297,22 @@ def _run_command(self, cur, sql_statement, parameters):
         if cur.rowcount >= 0:
             self.log.info("Rows affected: %s", cur.rowcount)
 
+    def _update_query_ids(self, cursor) -> None:

Review Comment:
   I think this method should be private.
   It's called only by `.run()` and should use the cursor to get a queryId.
   Different connectors do it in different ways. Like for the Snowflake 
`cursor.sfqid` and for the Presto `cursor.stats["queryId"]`.
   Theoretically, we could implement this method for Postgres like
   ```
   def _update_query_ids(self, cursor) -> None:
       cursor.execute("select pg_backend_pid()")
       self.query_ids.append(cursor.fetchone()[0][0])
   ```
   and then
   ```
   def kill_query(self, query_id) -> Any:
       result = super().run(sql=f"SELECT pg_terminate_backend({query_id});", 
handler=list)
       return result
   ```
   Of course, that's a bad example because after new execution we lose the 
returning data of the previous execution.



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