From 2cb0626134470b35689e5d82c2cb8e706299c0a4 Mon Sep 17 00:00:00 2001 From: Jens Scheffler Date: Thu, 5 Dec 2024 22:34:30 +0100 Subject: [PATCH 1/2] Remove Provider Deprecations in Sqlite --- .../airflow/providers/sqlite/CHANGELOG.rst | 13 +++ .../providers/sqlite/operators/__init__.py | 17 ---- .../providers/sqlite/operators/sqlite.py | 59 ------------- .../airflow/providers/sqlite/provider.yaml | 6 -- providers/tests/sqlite/operators/__init__.py | 17 ---- .../tests/sqlite/operators/test_sqlite.py | 85 ------------------- 6 files changed, 13 insertions(+), 184 deletions(-) delete mode 100644 providers/src/airflow/providers/sqlite/operators/__init__.py delete mode 100644 providers/src/airflow/providers/sqlite/operators/sqlite.py delete mode 100644 providers/tests/sqlite/operators/__init__.py delete mode 100644 providers/tests/sqlite/operators/test_sqlite.py diff --git a/providers/src/airflow/providers/sqlite/CHANGELOG.rst b/providers/src/airflow/providers/sqlite/CHANGELOG.rst index d69e941316447..33727da0ab1b7 100644 --- a/providers/src/airflow/providers/sqlite/CHANGELOG.rst +++ b/providers/src/airflow/providers/sqlite/CHANGELOG.rst @@ -27,6 +27,19 @@ Changelog --------- +main +.... + +Breaking changes +~~~~~~~~~~~~~~~~ + +.. warning:: + All deprecated classes, parameters and features have been removed from the Sqlite provider package. + The following breaking changes were introduced: + + * Operators + * Remove ``airflow.providers.sqlite.operators.sqlite.SqliteOperator``. Please use ``airflow.providers.common.sql.operators.sql.SQLExecuteQueryOperator``. + 3.9.1 ..... diff --git a/providers/src/airflow/providers/sqlite/operators/__init__.py b/providers/src/airflow/providers/sqlite/operators/__init__.py deleted file mode 100644 index 217e5db960782..0000000000000 --- a/providers/src/airflow/providers/sqlite/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/sqlite/operators/sqlite.py b/providers/src/airflow/providers/sqlite/operators/sqlite.py deleted file mode 100644 index 25df70c8abf72..0000000000000 --- a/providers/src/airflow/providers/sqlite/operators/sqlite.py +++ /dev/null @@ -1,59 +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 SqliteOperator(SQLExecuteQueryOperator): - """ - Executes sql code in a specific Sqlite 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:SqliteOperator` - - :param sql: the sql code to be executed. Can receive a str representing a - sql statement, a list of str (sql statements), or reference to a template file. - Template reference are recognized by str ending in '.sql' - (templated) - :param sqlite_conn_id: reference to a specific sqlite database - :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 = "#cdaaed" - - def __init__(self, *, sqlite_conn_id: str = "sqlite_default", **kwargs) -> None: - super().__init__(conn_id=sqlite_conn_id, **kwargs) diff --git a/providers/src/airflow/providers/sqlite/provider.yaml b/providers/src/airflow/providers/sqlite/provider.yaml index 473c211966e61..3ab2417cf2c06 100644 --- a/providers/src/airflow/providers/sqlite/provider.yaml +++ b/providers/src/airflow/providers/sqlite/provider.yaml @@ -68,12 +68,6 @@ integrations: logo: /integration-logos/sqlite/SQLite.png tags: [software] -operators: - - integration-name: SQLite - - python-modules: - - airflow.providers.sqlite.operators.sqlite - hooks: - integration-name: SQLite python-modules: diff --git a/providers/tests/sqlite/operators/__init__.py b/providers/tests/sqlite/operators/__init__.py deleted file mode 100644 index 217e5db960782..0000000000000 --- a/providers/tests/sqlite/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/sqlite/operators/test_sqlite.py b/providers/tests/sqlite/operators/test_sqlite.py deleted file mode 100644 index 7b95c5d932a58..0000000000000 --- a/providers/tests/sqlite/operators/test_sqlite.py +++ /dev/null @@ -1,85 +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 - -import pytest - -from airflow.models.dag import DAG -from airflow.providers.common.sql.operators.sql import SQLExecuteQueryOperator -from airflow.utils import timezone - -DEFAULT_DATE = timezone.datetime(2015, 1, 1) -DEFAULT_DATE_ISO = DEFAULT_DATE.isoformat() -DEFAULT_DATE_DS = DEFAULT_DATE_ISO[:10] -TEST_DAG_ID = "unit_test_dag" - - -@pytest.mark.backend("sqlite") -class TestSqliteOperator: - def setup_method(self): - args = {"owner": "airflow", "start_date": DEFAULT_DATE} - dag = DAG(TEST_DAG_ID, schedule=None, default_args=args) - self.dag = dag - - def teardown_method(self): - tables_to_drop = ["test_airflow", "test_airflow2"] - from airflow.providers.sqlite.hooks.sqlite import SqliteHook - - with SqliteHook().get_conn() as conn: - cur = conn.cursor() - for table in tables_to_drop: - cur.execute(f"DROP TABLE IF EXISTS {table}") - - def test_sqlite_operator_with_one_statement(self): - sql = """ - CREATE TABLE IF NOT EXISTS test_airflow ( - dummy VARCHAR(50) - ); - """ - op = SQLExecuteQueryOperator(task_id="basic_sqlite", sql=sql, dag=self.dag, conn_id="sqlite_default") - op.run(start_date=DEFAULT_DATE, end_date=DEFAULT_DATE, ignore_ti_state=True) - - def test_sqlite_operator_with_multiple_statements(self): - sql = [ - "CREATE TABLE IF NOT EXISTS test_airflow (dummy VARCHAR(50))", - "INSERT INTO test_airflow VALUES ('X')", - ] - op = SQLExecuteQueryOperator( - task_id="sqlite_operator_with_multiple_statements", - sql=sql, - dag=self.dag, - conn_id="sqlite_default", - ) - op.run(start_date=DEFAULT_DATE, end_date=DEFAULT_DATE, ignore_ti_state=True) - - def test_sqlite_operator_with_invalid_sql(self): - sql = [ - "CREATE TABLE IF NOT EXISTS test_airflow (dummy VARCHAR(50))", - "INSERT INTO test_airflow2 VALUES ('X')", - ] - - from sqlite3 import OperationalError - - op = SQLExecuteQueryOperator( - task_id="sqlite_operator_with_multiple_statements", - sql=sql, - dag=self.dag, - conn_id="sqlite_default", - ) - with pytest.raises(OperationalError, match="no such table: test_airflow2"): - op.run(start_date=DEFAULT_DATE, end_date=DEFAULT_DATE, ignore_ti_state=True) From 1bcc3289f21f9a6b7f917015fa64191dbd4fec29 Mon Sep 17 00:00:00 2001 From: Jens Scheffler Date: Fri, 6 Dec 2024 19:48:13 +0100 Subject: [PATCH 2/2] Adjust docs after deprecation --- docs/apache-airflow-providers-sqlite/operators.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/apache-airflow-providers-sqlite/operators.rst b/docs/apache-airflow-providers-sqlite/operators.rst index 5b113162ae4c3..086192325cdc8 100644 --- a/docs/apache-airflow-providers-sqlite/operators.rst +++ b/docs/apache-airflow-providers-sqlite/operators.rst @@ -25,8 +25,8 @@ SQLExecuteQueryOperator to connect to Sqlite Use the :class:`SQLExecuteQueryOperator` to execute Sqlite commands in a `Sqlite `__ database. -.. warning:: - Previously, SqliteOperator was used to perform this kind of operation. But at the moment SqliteOperator is deprecated and will be removed in future versions of the provider. Please consider to switch to SQLExecuteQueryOperator as soon as possible. +.. note:: + Previously, ``SqliteOperator`` was used to perform this kind of operation. After deprecation this has been removed. Please use ``SQLExecuteQueryOperator`` instead. Using the Operator ^^^^^^^^^^^^^^^^^^