Skip to content

Commit

Permalink
SnowflakeSqlApiOperator - Change the base class (#31751)
Browse files Browse the repository at this point in the history
* Change base class for SnowflakeSqlApiOperator

* Remove unwanted check
  • Loading branch information
utkarsharma2 committed Jun 11, 2023
1 parent 3206719 commit 35845f9
Showing 1 changed file with 13 additions and 20 deletions.
33 changes: 13 additions & 20 deletions airflow/providers/snowflake/operators/snowflake.py
Expand Up @@ -370,7 +370,7 @@ def __init__(
self.query_ids: list[str] = []


class SnowflakeSqlApiOperator(SnowflakeOperator):
class SnowflakeSqlApiOperator(SQLExecuteQueryOperator):
"""
Implemented Snowflake SQL API Operator to support multiple SQL statements sequentially,
which is the behavior of the SnowflakeOperator, the Snowflake SQL API allows submitting
Expand Down Expand Up @@ -459,25 +459,18 @@ def __init__(
self.token_renewal_delta = token_renewal_delta
self.bindings = bindings
self.execute_async = False
if self.__class__.__base__.__name__ != "SnowflakeOperator":
# It's better to do str check of the parent class name because currently SnowflakeOperator
# is deprecated and in future OSS SnowflakeOperator may be removed
if any(
[warehouse, database, role, schema, authenticator, session_parameters]
): # pragma: no cover
hook_params = kwargs.pop("hook_params", {}) # pragma: no cover
kwargs["hook_params"] = {
"warehouse": warehouse,
"database": database,
"role": role,
"schema": schema,
"authenticator": authenticator,
"session_parameters": session_parameters,
**hook_params,
}
super().__init__(conn_id=snowflake_conn_id, **kwargs) # pragma: no cover
else:
super().__init__(**kwargs)
if any([warehouse, database, role, schema, authenticator, session_parameters]): # pragma: no cover
hook_params = kwargs.pop("hook_params", {}) # pragma: no cover
kwargs["hook_params"] = {
"warehouse": warehouse,
"database": database,
"role": role,
"schema": schema,
"authenticator": authenticator,
"session_parameters": session_parameters,
**hook_params,
}
super().__init__(conn_id=snowflake_conn_id, **kwargs) # pragma: no cover

def execute(self, context: Context) -> None:
"""
Expand Down

0 comments on commit 35845f9

Please sign in to comment.