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

jscheffl 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 75b24e88b25 Remove Provider Deprecations in Microsoft-MSSQL (#44762)
75b24e88b25 is described below

commit 75b24e88b25a762b503e783154361ff978024340
Author: Jens Scheffler <[email protected]>
AuthorDate: Sat Dec 7 16:01:40 2024 +0100

    Remove Provider Deprecations in Microsoft-MSSQL (#44762)
---
 .../operators.rst                                  |  4 +-
 .../providers/microsoft/mssql/CHANGELOG.rst        | 13 ++++
 .../microsoft/mssql/operators/__init__.py          | 17 -----
 .../providers/microsoft/mssql/operators/mssql.py   | 73 ----------------------
 .../providers/microsoft/mssql/provider.yaml        |  5 --
 .../tests/microsoft/mssql/operators/__init__.py    | 16 -----
 .../tests/microsoft/mssql/operators/test_mssql.py  | 65 -------------------
 7 files changed, 15 insertions(+), 178 deletions(-)

diff --git a/docs/apache-airflow-providers-microsoft-mssql/operators.rst 
b/docs/apache-airflow-providers-microsoft-mssql/operators.rst
index 560e196731b..75955a2dc9a 100644
--- a/docs/apache-airflow-providers-microsoft-mssql/operators.rst
+++ b/docs/apache-airflow-providers-microsoft-mssql/operators.rst
@@ -25,8 +25,8 @@ The purpose of this guide is to define tasks involving 
interactions with the MSS
 Use the :class:`SQLExecuteQueryOperator 
<airflow.providers.common.sql.operators.sql>` to execute
 SQL commands in MSSQL database.
 
-.. warning::
-    Previously, MsSqlOperator was used to perform this kind of operation. But 
at the moment MsSqlOperator is deprecated and will be removed in future 
versions of the provider. Please consider to switch to SQLExecuteQueryOperator 
as soon as possible.
+.. note::
+    Previously, ``MsSqlOperator`` was used to perform this kind of operation. 
Please use ``SQLExecuteQueryOperator`` instead.
 
 Common Database Operations with SQLExecuteQueryOperator
 -------------------------------------------------------
diff --git a/providers/src/airflow/providers/microsoft/mssql/CHANGELOG.rst 
b/providers/src/airflow/providers/microsoft/mssql/CHANGELOG.rst
index 92c92943ac2..78fa7fd456f 100644
--- a/providers/src/airflow/providers/microsoft/mssql/CHANGELOG.rst
+++ b/providers/src/airflow/providers/microsoft/mssql/CHANGELOG.rst
@@ -27,6 +27,19 @@
 Changelog
 ---------
 
+main
+....
+
+Breaking changes
+~~~~~~~~~~~~~~~~
+
+.. warning::
+  All deprecated classes, parameters and features have been removed from the 
MySQL provider package.
+  The following breaking changes were introduced:
+
+  * Operators
+     * Remove 
``airflow.providers.microsoft.mssql.operators.mssql.MsSqlOperator``. Please use 
``airflow.providers.common.sql.operators.sql.SQLExecuteQueryOperator``.
+
 3.9.2
 .....
 
diff --git 
a/providers/src/airflow/providers/microsoft/mssql/operators/__init__.py 
b/providers/src/airflow/providers/microsoft/mssql/operators/__init__.py
deleted file mode 100644
index 217e5db9607..00000000000
--- a/providers/src/airflow/providers/microsoft/mssql/operators/__init__.py
+++ /dev/null
@@ -1,17 +0,0 @@
-#
-# Licensed to the Apache Software Foundation (ASF) under one
-# or more contributor license agreements.  See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership.  The ASF licenses this file
-# to you under the Apache License, Version 2.0 (the
-# "License"); you may not use this file except in compliance
-# with the License.  You may obtain a copy of the License at
-#
-#   http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing,
-# software distributed under the License is distributed on an
-# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-# KIND, either express or implied.  See the License for the
-# specific language governing permissions and limitations
-# under the License.
diff --git a/providers/src/airflow/providers/microsoft/mssql/operators/mssql.py 
b/providers/src/airflow/providers/microsoft/mssql/operators/mssql.py
deleted file mode 100644
index 3e698e6589b..00000000000
--- a/providers/src/airflow/providers/microsoft/mssql/operators/mssql.py
+++ /dev/null
@@ -1,73 +0,0 @@
-#
-# Licensed to the Apache Software Foundation (ASF) under one
-# or more contributor license agreements.  See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership.  The ASF licenses this file
-# to you under the Apache License, Version 2.0 (the
-# "License"); you may not use this file except in compliance
-# with the License.  You may obtain a copy of the License at
-#
-#   http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing,
-# software distributed under the License is distributed on an
-# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-# KIND, either express or implied.  See the License for the
-# specific language governing permissions and limitations
-# under the License.
-from __future__ import annotations
-
-from collections.abc import Sequence
-from typing import ClassVar
-
-from deprecated import deprecated
-
-from airflow.exceptions import AirflowProviderDeprecationWarning
-from airflow.providers.common.sql.operators.sql import SQLExecuteQueryOperator
-
-
-@deprecated(
-    reason=(
-        "Please use 
`airflow.providers.common.sql.operators.sql.SQLExecuteQueryOperator`."
-        "Also, you can provide `hook_params={'schema': <database>}`."
-    ),
-    category=AirflowProviderDeprecationWarning,
-)
-class MsSqlOperator(SQLExecuteQueryOperator):
-    """
-    Executes sql code in a specific Microsoft SQL database.
-
-    .. seealso::
-        For more information on how to use this operator, take a look at the 
guide:
-        :ref:`howto/operator:MsSqlOperator`
-
-    This operator may use one of two hooks, depending on the ``conn_type`` of 
the connection.
-
-    If conn_type is ``'odbc'``, then 
:py:class:`~airflow.providers.odbc.hooks.odbc.OdbcHook`
-    is used.  Otherwise, 
:py:class:`~airflow.providers.microsoft.mssql.hooks.mssql.MsSqlHook` is used.
-
-    This class is deprecated.
-
-    Please use 
:class:`airflow.providers.common.sql.operators.sql.SQLExecuteQueryOperator`.
-
-    :param sql: the sql code to be executed (templated)
-    :param mssql_conn_id: reference to a specific mssql database
-    :param parameters: (optional) the parameters to render the SQL query with.
-    :param autocommit: if True, each command is automatically committed.
-        (default value: False)
-    :param database: name of database which overwrite defined one in connection
-    """
-
-    template_fields: Sequence[str] = ("sql",)
-    template_ext: Sequence[str] = (".sql",)
-    template_fields_renderers: ClassVar[dict] = {"sql": "tsql"}
-    ui_color = "#ededed"
-
-    def __init__(
-        self, *, mssql_conn_id: str = "mssql_default", database: str | None = 
None, **kwargs
-    ) -> None:
-        if database is not None:
-            hook_params = kwargs.pop("hook_params", {})
-            kwargs["hook_params"] = {"schema": database, **hook_params}
-
-        super().__init__(conn_id=mssql_conn_id, **kwargs)
diff --git a/providers/src/airflow/providers/microsoft/mssql/provider.yaml 
b/providers/src/airflow/providers/microsoft/mssql/provider.yaml
index f186423668d..de96f1500f7 100644
--- a/providers/src/airflow/providers/microsoft/mssql/provider.yaml
+++ b/providers/src/airflow/providers/microsoft/mssql/provider.yaml
@@ -71,11 +71,6 @@ integrations:
       - /docs/apache-airflow-providers-microsoft-mssql/operators.rst
     tags: [software]
 
-operators:
-  - integration-name: Microsoft SQL Server (MSSQL)
-    python-modules:
-      - airflow.providers.microsoft.mssql.operators.mssql
-
 hooks:
   - integration-name: Microsoft SQL Server (MSSQL)
     python-modules:
diff --git a/providers/tests/microsoft/mssql/operators/__init__.py 
b/providers/tests/microsoft/mssql/operators/__init__.py
deleted file mode 100644
index 13a83393a91..00000000000
--- a/providers/tests/microsoft/mssql/operators/__init__.py
+++ /dev/null
@@ -1,16 +0,0 @@
-# Licensed to the Apache Software Foundation (ASF) under one
-# or more contributor license agreements.  See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership.  The ASF licenses this file
-# to you under the Apache License, Version 2.0 (the
-# "License"); you may not use this file except in compliance
-# with the License.  You may obtain a copy of the License at
-#
-#   http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing,
-# software distributed under the License is distributed on an
-# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-# KIND, either express or implied.  See the License for the
-# specific language governing permissions and limitations
-# under the License.
diff --git a/providers/tests/microsoft/mssql/operators/test_mssql.py 
b/providers/tests/microsoft/mssql/operators/test_mssql.py
deleted file mode 100644
index 8f2311ec769..00000000000
--- a/providers/tests/microsoft/mssql/operators/test_mssql.py
+++ /dev/null
@@ -1,65 +0,0 @@
-#
-# Licensed to the Apache Software Foundation (ASF) under one
-# or more contributor license agreements.  See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership.  The ASF licenses this file
-# to you under the Apache License, Version 2.0 (the
-# "License"); you may not use this file except in compliance
-# with the License.  You may obtain a copy of the License at
-#
-#   http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing,
-# software distributed under the License is distributed on an
-# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-# KIND, either express or implied.  See the License for the
-# specific language governing permissions and limitations
-# under the License.
-from __future__ import annotations
-
-from unittest import mock
-from unittest.mock import MagicMock, Mock
-
-import pytest
-
-from airflow.exceptions import AirflowException
-from airflow.providers.common.sql.operators.sql import SQLExecuteQueryOperator
-
-try:
-    from airflow.providers.microsoft.mssql.hooks.mssql import MsSqlHook
-except ImportError:
-    pytest.skip("MSSQL not available", allow_module_level=True)
-
-MSSQL_DEFAULT = "mssql_default"
-
-
-class TestMsSqlOperator:
-    
@mock.patch("airflow.providers.common.sql.operators.sql.SQLExecuteQueryOperator.get_db_hook")
-    def test_get_hook_from_conn(self, mock_get_db_hook):
-        """
-        :class:`~.MsSqlOperator` should use the hook returned by 
:meth:`airflow.models.Connection.get_hook`
-        if one is returned.
-
-        This behavior is necessary in order to support usage of 
:class:`~.OdbcHook` with this operator.
-
-        Specifically we verify here that :meth:`~.MsSqlOperator.get_hook` 
returns the hook returned from a
-        call of ``get_hook`` on the object returned from 
:meth:`~.BaseHook.get_connection`.
-        """
-        mock_hook = MagicMock()
-        mock_get_db_hook.return_value = mock_hook
-
-        op = SQLExecuteQueryOperator(task_id="test", sql="", 
conn_id=MSSQL_DEFAULT)
-        assert op.get_db_hook() == mock_hook
-
-    @mock.patch(
-        
"airflow.providers.common.sql.operators.sql.SQLExecuteQueryOperator.get_db_hook",
 autospec=MsSqlHook
-    )
-    def test_get_hook_default(self, mock_get_db_hook):
-        """
-        If :meth:`airflow.models.Connection.get_hook` does not return a hook 
(e.g. because of an invalid
-        conn type), then :class:`~.MsSqlHook` should be used.
-        """
-        mock_get_db_hook.return_value.side_effect = 
Mock(side_effect=AirflowException())
-
-        op = SQLExecuteQueryOperator(task_id="test", sql="", 
conn_id=MSSQL_DEFAULT)
-        assert op.get_db_hook().__class__.__name__ == "MsSqlHook"

Reply via email to