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 ee6167e1505 remove deprecations (#44756)
ee6167e1505 is described below
commit ee6167e1505d69f392fb20cce8c32ec3bd2a0f1a
Author: vatsrahul1001 <[email protected]>
AuthorDate: Sat Dec 7 16:03:07 2024 +0530
remove deprecations (#44756)
---
.../src/airflow/providers/snowflake/CHANGELOG.rst | 9 ++
.../airflow/providers/snowflake/hooks/snowflake.py | 3 -
.../providers/snowflake/operators/snowflake.py | 107 +--------------------
3 files changed, 12 insertions(+), 107 deletions(-)
diff --git a/providers/src/airflow/providers/snowflake/CHANGELOG.rst
b/providers/src/airflow/providers/snowflake/CHANGELOG.rst
index 3eb83f39e75..a61a808e599 100644
--- a/providers/src/airflow/providers/snowflake/CHANGELOG.rst
+++ b/providers/src/airflow/providers/snowflake/CHANGELOG.rst
@@ -27,6 +27,15 @@
Changelog
---------
+main
+....
+
+.. warning::
+ All deprecated classes, parameters and features have been removed from the
snowflake provider package.
+ The following breaking changes were introduced:
+
+ * Removed deprecated ``SnowflakeOperator``. Use ``SQLExecuteQueryOperator``
instead.
+
5.8.1
.....
diff --git a/providers/src/airflow/providers/snowflake/hooks/snowflake.py
b/providers/src/airflow/providers/snowflake/hooks/snowflake.py
index f9e40942bb3..5571ac8fc66 100644
--- a/providers/src/airflow/providers/snowflake/hooks/snowflake.py
+++ b/providers/src/airflow/providers/snowflake/hooks/snowflake.py
@@ -82,9 +82,6 @@ class SnowflakeHook(DbApiHook):
.. note::
``get_sqlalchemy_engine()`` depends on ``snowflake-sqlalchemy``
- .. seealso::
- For more information on how to use this Snowflake connection, take a
look at the guide:
- :ref:`howto/operator:SnowflakeOperator`
"""
conn_name_attr = "snowflake_conn_id"
diff --git a/providers/src/airflow/providers/snowflake/operators/snowflake.py
b/providers/src/airflow/providers/snowflake/operators/snowflake.py
index 859e88d7d27..ffce0c56325 100644
--- a/providers/src/airflow/providers/snowflake/operators/snowflake.py
+++ b/providers/src/airflow/providers/snowflake/operators/snowflake.py
@@ -20,12 +20,10 @@ from __future__ import annotations
import time
from collections.abc import Iterable, Mapping, Sequence
from datetime import timedelta
-from typing import TYPE_CHECKING, Any, ClassVar, SupportsAbs, cast
-
-from deprecated import deprecated
+from typing import TYPE_CHECKING, Any, SupportsAbs, cast
from airflow.configuration import conf
-from airflow.exceptions import AirflowException,
AirflowProviderDeprecationWarning
+from airflow.exceptions import AirflowException
from airflow.providers.common.sql.operators.sql import (
SQLCheckOperator,
SQLExecuteQueryOperator,
@@ -39,105 +37,6 @@ if TYPE_CHECKING:
from airflow.utils.context import Context
-@deprecated(
- reason=(
- "This class is deprecated. Please use "
- "`airflow.providers.common.sql.operators.sql.SQLExecuteQueryOperator`.
"
- "Also, you can provide `hook_params={'warehouse': <warehouse>,
'database': <database>, "
- "'role': <role>, 'schema': <schema>, 'authenticator': <authenticator>,"
- "'session_parameters': <session_parameters>}`."
- ),
- category=AirflowProviderDeprecationWarning,
-)
-class SnowflakeOperator(SQLExecuteQueryOperator):
- """
- Executes SQL code in a Snowflake database.
-
- This class is deprecated.
-
- Please use
:class:`airflow.providers.common.sql.operators.sql.SQLExecuteQueryOperator`.
-
- .. seealso::
- For more information on how to use this operator, take a look at the
guide:
- :ref:`howto/operator:SnowflakeOperator`
-
- :param snowflake_conn_id: Reference to
- :ref:`Snowflake connection id<howto/connection:snowflake>`
- :param sql: the SQL code to be executed as a single string, or
- a list of str (sql statements), or a reference to a template file.
- Template references are recognized by str ending in '.sql'
- :param parameters: (optional) the parameters to render the SQL query with.
- :param warehouse: name of warehouse (will overwrite any warehouse
- defined in the connection's extra JSON)
- :param database: name of database (will overwrite database defined
- in connection)
- :param schema: name of schema (will overwrite schema defined in
- connection)
- :param role: name of role (will overwrite any role defined in
- connection's extra JSON)
- :param authenticator: authenticator for Snowflake.
- 'snowflake' (default) to use the internal Snowflake authenticator
- 'externalbrowser' to authenticate using your web browser and
- Okta, ADFS or any other SAML 2.0-compliant identify provider
- (IdP) that has been defined for your account
- 'https://<your_okta_account_name>.okta.com' to authenticate
- through native Okta.
- :param session_parameters: You can set session-level parameters at
- the time you connect to Snowflake
- :return Returns list of dictionaries in { 'column': 'value', 'column2':
'value2' } form.
- """
-
- template_fields: Sequence[str] = ("sql",)
- template_ext: Sequence[str] = (".sql",)
- template_fields_renderers: ClassVar[dict] = {"sql": "sql"}
- ui_color = "#ededed"
-
- def __init__(
- self,
- *,
- snowflake_conn_id: str = "snowflake_default",
- warehouse: str | None = None,
- database: str | None = None,
- role: str | None = None,
- schema: str | None = None,
- authenticator: str | None = None,
- session_parameters: dict | None = None,
- **kwargs,
- ) -> None:
- if any([warehouse, database, role, schema, authenticator,
session_parameters]):
- hook_params = kwargs.pop("hook_params", {})
- 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)
-
- def _process_output(self, results: list[Any], descriptions:
list[Sequence[Sequence] | None]) -> list[Any]:
- validated_descriptions: list[Sequence[Sequence]] = []
- for idx, description in enumerate(descriptions):
- if not description:
- raise RuntimeError(
- f"The query did not return descriptions of the cursor for
query number {idx}. "
- "Cannot return values in a form of dictionary for that
query."
- )
- validated_descriptions.append(description)
- returned_results = []
- for result_id, result_list in enumerate(results):
- current_processed_result = []
- for row in result_list:
- dict_result: dict[Any, Any] = {}
- for idx, description in
enumerate(validated_descriptions[result_id]):
- dict_result[description[0]] = row[idx]
- current_processed_result.append(dict_result)
- returned_results.append(current_processed_result)
- return returned_results
-
-
class SnowflakeCheckOperator(SQLCheckOperator):
"""
Performs a check against Snowflake.
@@ -392,7 +291,7 @@ class
SnowflakeIntervalCheckOperator(SQLIntervalCheckOperator):
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
+ which is the behavior of the SQLExecuteQueryOperator, the Snowflake SQL
API allows submitting
multiple SQL statements in a single request. It make post request to
submit SQL
statements for execution, poll to check the status of the execution of a
statement. Fetch query results
concurrently.