You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by po...@apache.org on 2021/11/27 16:56:40 UTC

[airflow] branch main updated: Renamed Connection.get_hook parameter to make it the same as in SqlSensor and SqlOperator. (#19849)

This is an automated email from the ASF dual-hosted git repository.

potiuk pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/airflow.git


The following commit(s) were added to refs/heads/main by this push:
     new 5a5d50d  Renamed Connection.get_hook parameter to make it the same as in SqlSensor and SqlOperator. (#19849)
5a5d50d is described below

commit 5a5d50d1e347dfc8d8ee99370c41de3106dea558
Author: Dmytro Kazanzhy <dk...@gmail.com>
AuthorDate: Sat Nov 27 18:56:15 2021 +0200

    Renamed Connection.get_hook parameter to make it the same as in SqlSensor and SqlOperator. (#19849)
---
 airflow/models/connection.py | 8 ++++----
 airflow/operators/sql.py     | 2 +-
 airflow/sensors/sql.py       | 2 +-
 3 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/airflow/models/connection.py b/airflow/models/connection.py
index 19ba82d..b3261a4 100644
--- a/airflow/models/connection.py
+++ b/airflow/models/connection.py
@@ -285,7 +285,7 @@ class Connection(Base, LoggingMixin):
         if self._extra and self.is_extra_encrypted:
             self._extra = fernet.rotate(self._extra.encode('utf-8')).decode()
 
-    def get_hook(self, *, hook_kwargs=None):
+    def get_hook(self, *, hook_params=None):
         """Return hook based on conn_type"""
         (
             hook_class_name,
@@ -304,9 +304,9 @@ class Connection(Base, LoggingMixin):
                 "Could not import %s when discovering %s %s", hook_class_name, hook_name, package_name
             )
             raise
-        if hook_kwargs is None:
-            hook_kwargs = {}
-        return hook_class(**{conn_id_param: self.conn_id}, **hook_kwargs)
+        if hook_params is None:
+            hook_params = {}
+        return hook_class(**{conn_id_param: self.conn_id}, **hook_params)
 
     def __repr__(self):
         return self.conn_id
diff --git a/airflow/operators/sql.py b/airflow/operators/sql.py
index 8ec3698..0ad5b21 100644
--- a/airflow/operators/sql.py
+++ b/airflow/operators/sql.py
@@ -65,7 +65,7 @@ class BaseSQLOperator(BaseOperator):
         self.log.debug("Get connection for %s", self.conn_id)
         conn = BaseHook.get_connection(self.conn_id)
 
-        hook = conn.get_hook(hook_kwargs=self.hook_params)
+        hook = conn.get_hook(hook_params=self.hook_params)
         if not isinstance(hook, DbApiHook):
             raise AirflowException(
                 f'The connection type is not supported by {self.__class__.__name__}. '
diff --git a/airflow/sensors/sql.py b/airflow/sensors/sql.py
index 2708f63..ad4dfa4 100644
--- a/airflow/sensors/sql.py
+++ b/airflow/sensors/sql.py
@@ -103,7 +103,7 @@ class SqlSensor(BaseSensorOperator):
                 f"Connection type ({conn.conn_type}) is not supported by SqlSensor. "
                 + f"Supported connection types: {list(allowed_conn_type)}"
             )
-        return conn.get_hook(hook_kwargs=self.hook_params)
+        return conn.get_hook(hook_params=self.hook_params)
 
     def poke(self, context):
         hook = self._get_hook()