You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by GitBox <gi...@apache.org> on 2021/11/17 07:37:03 UTC

[GitHub] [airflow] uranusjr commented on a change in pull request #18431: Add `hook_params` and fix `allowed_conn_types` for SqlSensor.

uranusjr commented on a change in pull request #18431:
URL: https://github.com/apache/airflow/pull/18431#discussion_r750961965



##########
File path: airflow/sensors/sql.py
##########
@@ -58,39 +62,35 @@ class SqlSensor(BaseSensorOperator):
     ui_color = '#7c7287'
 
     def __init__(
-        self, *, conn_id, sql, parameters=None, success=None, failure=None, fail_on_empty=False, **kwargs
+        self,
+        *,
+        conn_id,
+        sql,
+        parameters=None,
+        success=None,
+        failure=None,
+        fail_on_empty=False,
+        hook_params=None,

Review comment:
       I wonder if we should use `hook_kwargs` for consistency with `Connection.get_hook()`.

##########
File path: airflow/sensors/sql.py
##########
@@ -58,39 +62,35 @@ class SqlSensor(BaseSensorOperator):
     ui_color = '#7c7287'
 
     def __init__(
-        self, *, conn_id, sql, parameters=None, success=None, failure=None, fail_on_empty=False, **kwargs
+        self,
+        *,
+        conn_id,
+        sql,
+        parameters=None,
+        success=None,
+        failure=None,
+        fail_on_empty=False,
+        hook_params=None,
+        **kwargs
     ):
         self.conn_id = conn_id
         self.sql = sql
         self.parameters = parameters
         self.success = success
         self.failure = failure
         self.fail_on_empty = fail_on_empty
+        self.hook_params = {} if hook_params is None else hook_params

Review comment:
       The `if-else` is not needed since `Connection.get_hook()` handled None automatically.
   
   ```suggestion
           self.hook_params = hook_params
   ```




-- 
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: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org