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 2688d7ce6ff Remove Provider Deprecations in Common SQL (#44645)
2688d7ce6ff is described below
commit 2688d7ce6ff29190e4e51ce2aa28dcbf9a467866
Author: LIU ZHE YOU <[email protected]>
AuthorDate: Fri Dec 6 04:00:00 2024 +0800
Remove Provider Deprecations in Common SQL (#44645)
* Remove Provider Deprecations in Common SQL
* Fix Changelog header
Co-authored-by: Jens Scheffler <[email protected]>
---------
Co-authored-by: Jens Scheffler <[email protected]>
---
.../src/airflow/providers/common/sql/CHANGELOG.rst | 10 ++++++++++
.../src/airflow/providers/common/sql/hooks/sql.py | 12 ------------
providers/tests/common/sql/hooks/test_sql.py | 19 -------------------
scripts/ci/pre_commit/check_common_sql_dependency.py | 4 ++--
4 files changed, 12 insertions(+), 33 deletions(-)
diff --git a/providers/src/airflow/providers/common/sql/CHANGELOG.rst
b/providers/src/airflow/providers/common/sql/CHANGELOG.rst
index 6a8de8841c7..ef212ce1081 100644
--- a/providers/src/airflow/providers/common/sql/CHANGELOG.rst
+++ b/providers/src/airflow/providers/common/sql/CHANGELOG.rst
@@ -25,6 +25,16 @@
Changelog
---------
+main
+.....
+
+.. warning::
+ All deprecated classes, parameters and features have been removed from the
Common SQL provider package.
+ The following breaking changes were introduced:
+
+ * Hooks
+ * Remove ``_make_serializable`` method from ``DbApiHook``. Use
``_make_common_data_structure`` instead.
+
1.20.0
......
diff --git a/providers/src/airflow/providers/common/sql/hooks/sql.py
b/providers/src/airflow/providers/common/sql/hooks/sql.py
index d124b404d62..bd8780a750d 100644
--- a/providers/src/airflow/providers/common/sql/hooks/sql.py
+++ b/providers/src/airflow/providers/common/sql/hooks/sql.py
@@ -41,7 +41,6 @@ from sqlalchemy.engine import Inspector
from airflow.exceptions import (
AirflowException,
AirflowOptionalProviderFeatureException,
- AirflowProviderDeprecationWarning,
)
from airflow.hooks.base import BaseHook
@@ -502,17 +501,6 @@ class DbApiHook(BaseHook):
If this method is not overridden, the result data is returned as-is.
If the output of the cursor
is already a common data structure, this method should be ignored.
"""
- # Back-compatibility call for providers implementing old
ยด_make_serializable' method.
- with contextlib.suppress(AttributeError):
- result = self._make_serializable(result=result) # type:
ignore[attr-defined]
- warnings.warn(
- "The `_make_serializable` method is deprecated and support
will be removed in a future "
- f"version of the common.sql provider. Please update the
{self.__class__.__name__}'s provider "
- "to a version based on common.sql >= 1.9.1.",
- AirflowProviderDeprecationWarning,
- stacklevel=2,
- )
-
if isinstance(result, Sequence):
return cast(list[tuple], result)
return cast(tuple, result)
diff --git a/providers/tests/common/sql/hooks/test_sql.py
b/providers/tests/common/sql/hooks/test_sql.py
index 05d4ae1418f..756663ca39c 100644
--- a/providers/tests/common/sql/hooks/test_sql.py
+++ b/providers/tests/common/sql/hooks/test_sql.py
@@ -20,13 +20,11 @@ from __future__ import annotations
import logging
import logging.config
-import warnings
from unittest.mock import MagicMock
import pytest
from airflow.config_templates.airflow_local_settings import
DEFAULT_LOGGING_CONFIG
-from airflow.exceptions import AirflowProviderDeprecationWarning
from airflow.models import Connection
from airflow.providers.common.sql.hooks.sql import DbApiHook, fetch_all_handler
from airflow.utils.session import provide_session
@@ -238,23 +236,6 @@ class TestDbApiHook:
dbapi_hook.run(sql=empty_statement)
assert err.value.args[0] == "List of SQL statements is empty"
- @pytest.mark.db_test
- def test_make_common_data_structure_hook_has_deprecated_method(self):
- """If hook implements ``_make_serializable`` warning should be raised
on call."""
- hook = mock_hook(DbApiHook)
- hook._make_serializable = lambda result: result
- with pytest.warns(
- AirflowProviderDeprecationWarning, match="`_make_serializable`
method is deprecated"
- ):
- hook._make_common_data_structure(["foo", "bar", "baz"])
-
- @pytest.mark.db_test
- def test_make_common_data_structure_no_deprecated_method(self):
- """If hook not implements ``_make_serializable`` there is no warning
should be raised on call."""
- with warnings.catch_warnings():
- warnings.simplefilter("error", AirflowProviderDeprecationWarning)
- mock_hook(DbApiHook)._make_common_data_structure(["foo", "bar",
"baz"])
-
@pytest.mark.db_test
def test_placeholder_config_from_extra(self):
dbapi_hook = mock_hook(DbApiHook, conn_params={"extra":
{"placeholder": "?"}})
diff --git a/scripts/ci/pre_commit/check_common_sql_dependency.py
b/scripts/ci/pre_commit/check_common_sql_dependency.py
index b1373262e06..dbbca88bba3 100755
--- a/scripts/ci/pre_commit/check_common_sql_dependency.py
+++ b/scripts/ci/pre_commit/check_common_sql_dependency.py
@@ -53,7 +53,7 @@ def is_subclass_of_dbapihook(node: ast.ClassDef) -> bool:
return False
-def has_make_serializable_method(node: ast.ClassDef) -> bool:
+def has_make_common_data_structure_method(node: ast.ClassDef) -> bool:
"""Return True if the given class implements `_make_common_data_structure`
method."""
for body_element in node.body:
if isinstance(body_element, ast.FunctionDef) and (body_element.name ==
MAKE_COMMON_METHOD_NAME):
@@ -98,7 +98,7 @@ def check_sql_providers_dependency():
continue
for clazz in get_classes(path):
- if is_subclass_of_dbapihook(node=clazz) and
has_make_serializable_method(node=clazz):
+ if is_subclass_of_dbapihook(node=clazz) and
has_make_common_data_structure_method(node=clazz):
provider_yaml_path: str =
determine_provider_yaml_path(file_path=path)
provider_metadata: dict =
get_yaml_content(file_path=provider_yaml_path)