Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rename Connection.get_hook parameter to make it the same as in SqlSe… #19849

Merged
merged 1 commit into from
Nov 27, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions airflow/models/connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,7 @@ def rotate_fernet_key(self):
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,
Expand All @@ -304,9 +304,9 @@ def get_hook(self, *, hook_kwargs=None):
"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
Expand Down
2 changes: 1 addition & 1 deletion airflow/operators/sql.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ def _hook(self):
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__}. '
Expand Down
2 changes: 1 addition & 1 deletion airflow/sensors/sql.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ def _get_hook(self):
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()
Expand Down