From 676ffd92060e73085ce088468c2c44fbb4c55628 Mon Sep 17 00:00:00 2001 From: Jens Scheffler Date: Wed, 4 Dec 2024 22:27:41 +0100 Subject: [PATCH] Remove Provider Deprecations in JDBC --- .../src/airflow/providers/jdbc/CHANGELOG.rst | 13 ++++ .../providers/jdbc/operators/__init__.py | 17 ----- .../airflow/providers/jdbc/operators/jdbc.py | 62 ------------------- .../src/airflow/providers/jdbc/provider.yaml | 4 -- providers/tests/jdbc/operators/__init__.py | 17 ----- providers/tests/jdbc/operators/test_jdbc.py | 56 ----------------- 6 files changed, 13 insertions(+), 156 deletions(-) delete mode 100644 providers/src/airflow/providers/jdbc/operators/__init__.py delete mode 100644 providers/src/airflow/providers/jdbc/operators/jdbc.py delete mode 100644 providers/tests/jdbc/operators/__init__.py delete mode 100644 providers/tests/jdbc/operators/test_jdbc.py diff --git a/providers/src/airflow/providers/jdbc/CHANGELOG.rst b/providers/src/airflow/providers/jdbc/CHANGELOG.rst index 3eaaffd5859aa..909136b7edc1f 100644 --- a/providers/src/airflow/providers/jdbc/CHANGELOG.rst +++ b/providers/src/airflow/providers/jdbc/CHANGELOG.rst @@ -26,6 +26,19 @@ Changelog --------- +main +.... + +Breaking changes +~~~~~~~~~~~~~~~~ + +.. warning:: + All deprecated classes, parameters and features have been removed from the JDBC provider package. + The following breaking changes were introduced: + + * Operators + * Remove ``airflow.providers.jdbc.operators.jdbc.JdbcOperator``. Please use ``airflow.providers.common.sql.operators.sql.SQLExecuteQueryOperator`` instead. + 4.5.3 ..... diff --git a/providers/src/airflow/providers/jdbc/operators/__init__.py b/providers/src/airflow/providers/jdbc/operators/__init__.py deleted file mode 100644 index 217e5db960782..0000000000000 --- a/providers/src/airflow/providers/jdbc/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/jdbc/operators/jdbc.py b/providers/src/airflow/providers/jdbc/operators/jdbc.py deleted file mode 100644 index 5b721422d3733..0000000000000 --- a/providers/src/airflow/providers/jdbc/operators/jdbc.py +++ /dev/null @@ -1,62 +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`.", - category=AirflowProviderDeprecationWarning, -) -class JdbcOperator(SQLExecuteQueryOperator): - """ - Executes sql code in a database using jdbc driver. - - Requires jaydebeapi. - - This class is deprecated. - - Please use :class:`airflow.providers.common.sql.operators.sql.SQLExecuteQueryOperator` instead. - - .. seealso:: - For more information on how to use this operator, take a look at the guide: - :ref:`howto/operator:JdbcOperator` - - :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 jdbc_conn_id: reference to a predefined database - :param autocommit: if True, each command is automatically committed. - (default value: False) - :param parameters: (optional) the parameters to render the SQL query with. - """ - - template_fields: Sequence[str] = ("sql",) - template_ext: Sequence[str] = (".sql",) - template_fields_renderers: ClassVar[dict] = {"sql": "sql"} - ui_color = "#ededed" - - def __init__(self, *, jdbc_conn_id: str = "jdbc_default", **kwargs) -> None: - super().__init__(conn_id=jdbc_conn_id, **kwargs) diff --git a/providers/src/airflow/providers/jdbc/provider.yaml b/providers/src/airflow/providers/jdbc/provider.yaml index 91ec8dc271522..28f746afb1c5a 100644 --- a/providers/src/airflow/providers/jdbc/provider.yaml +++ b/providers/src/airflow/providers/jdbc/provider.yaml @@ -67,10 +67,6 @@ integrations: logo: /integration-logos/jdbc/JDBC.png tags: [protocol] -operators: - - integration-name: Java Database Connectivity (JDBC) - python-modules: - - airflow.providers.jdbc.operators.jdbc hooks: - integration-name: Java Database Connectivity (JDBC) python-modules: diff --git a/providers/tests/jdbc/operators/__init__.py b/providers/tests/jdbc/operators/__init__.py deleted file mode 100644 index 217e5db960782..0000000000000 --- a/providers/tests/jdbc/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/tests/jdbc/operators/test_jdbc.py b/providers/tests/jdbc/operators/test_jdbc.py deleted file mode 100644 index 97bc66a565a38..0000000000000 --- a/providers/tests/jdbc/operators/test_jdbc.py +++ /dev/null @@ -1,56 +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.mock import patch - -from airflow.providers.common.sql.hooks.sql import fetch_all_handler -from airflow.providers.common.sql.operators.sql import SQLExecuteQueryOperator - -JDBC_DEFAULT = "jdbc_default" - - -class TestJdbcOperator: - def setup_method(self): - self.kwargs = dict(sql="sql", task_id="test_jdbc_operator", dag=None) - - @patch("airflow.providers.common.sql.operators.sql.SQLExecuteQueryOperator.get_db_hook") - def test_execute_do_push(self, mock_get_db_hook): - jdbc_operator = SQLExecuteQueryOperator(**self.kwargs, do_xcom_push=True, conn_id=JDBC_DEFAULT) - jdbc_operator.execute(context={}) - - mock_get_db_hook.return_value.run.assert_called_once_with( - sql=jdbc_operator.sql, - autocommit=jdbc_operator.autocommit, - handler=fetch_all_handler, - parameters=jdbc_operator.parameters, - return_last=True, - ) - - @patch("airflow.providers.common.sql.operators.sql.SQLExecuteQueryOperator.get_db_hook") - def test_execute_dont_push(self, mock_get_db_hook): - jdbc_operator = SQLExecuteQueryOperator(**self.kwargs, do_xcom_push=False, conn_id=JDBC_DEFAULT) - jdbc_operator.execute(context={}) - - mock_get_db_hook.return_value.run.assert_called_once_with( - sql=jdbc_operator.sql, - autocommit=jdbc_operator.autocommit, - parameters=jdbc_operator.parameters, - handler=None, - return_last=True, - )