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

shahar 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 c894dab2013 Remove deprecations from Teradata Provider (#44746)
c894dab2013 is described below

commit c894dab20136ca11f096effacd5c58b794129d79
Author: vatsrahul1001 <[email protected]>
AuthorDate: Sat Dec 7 12:37:38 2024 +0530

    Remove deprecations from Teradata Provider (#44746)
---
 .../src/airflow/providers/teradata/CHANGELOG.rst   | 10 ++++
 .../airflow/providers/teradata/hooks/teradata.py   | 36 --------------
 .../teradata/transfers/teradata_to_teradata.py     |  2 +-
 providers/tests/teradata/hooks/test_teradata.py    | 55 ----------------------
 .../transfers/test_teradata_to_teradata.py         |  2 +-
 5 files changed, 12 insertions(+), 93 deletions(-)

diff --git a/providers/src/airflow/providers/teradata/CHANGELOG.rst 
b/providers/src/airflow/providers/teradata/CHANGELOG.rst
index 622661ab26a..b8a9141385e 100644
--- a/providers/src/airflow/providers/teradata/CHANGELOG.rst
+++ b/providers/src/airflow/providers/teradata/CHANGELOG.rst
@@ -25,6 +25,16 @@
 Changelog
 ---------
 
+main
+....
+
+.. warning::
+  All deprecated classes, parameters and features have been removed from the 
teradata provider package.
+  The following breaking changes were introduced:
+
+  * Removed deprecated ``bulk_insert_rows`` method from ``hooks``. Use 
``insert_rows`` instead.
+
+
 2.6.1
 .....
 
diff --git a/providers/src/airflow/providers/teradata/hooks/teradata.py 
b/providers/src/airflow/providers/teradata/hooks/teradata.py
index f4e6348ad0f..0742bc37436 100644
--- a/providers/src/airflow/providers/teradata/hooks/teradata.py
+++ b/providers/src/airflow/providers/teradata/hooks/teradata.py
@@ -20,14 +20,12 @@
 from __future__ import annotations
 
 import re
-import warnings
 from typing import TYPE_CHECKING, Any
 
 import sqlalchemy
 import teradatasql
 from teradatasql import TeradataConnection
 
-from airflow.exceptions import AirflowProviderDeprecationWarning
 from airflow.providers.common.sql.hooks.sql import DbApiHook
 
 if TYPE_CHECKING:
@@ -160,40 +158,6 @@ class TeradataHook(DbApiHook):
         except Exception as ex:
             self.log.error("Error occurred while setting session query band: 
%s ", str(ex))
 
-    def bulk_insert_rows(
-        self,
-        table: str,
-        rows: list[tuple],
-        target_fields: list[str] | None = None,
-        commit_every: int = 5000,
-    ):
-        """
-        Use :func:`insert_rows` instead, this is deprecated.
-
-        Insert bulk of records into Teradata SQL Database.
-
-        This uses prepared statements via `executemany()`. For best 
performance,
-        pass in `rows` as an iterator.
-
-        :param table: target Teradata database table, use dot notation to 
target a
-            specific database
-        :param rows: the rows to insert into the table
-        :param target_fields: the names of the columns to fill in the table, 
default None.
-            If None, each row should have some order as table columns name
-        :param commit_every: the maximum number of rows to insert in one 
transaction
-            Default 5000. Set greater than 0. Set 1 to insert each row in each 
transaction
-        """
-        warnings.warn(
-            "bulk_insert_rows is deprecated. Please use the insert_rows method 
instead.",
-            AirflowProviderDeprecationWarning,
-            stacklevel=2,
-        )
-
-        if not rows:
-            raise ValueError("parameter rows could not be None or empty 
iterable")
-
-        self.insert_rows(table=table, rows=rows, target_fields=target_fields, 
commit_every=commit_every)
-
     def _get_conn_config_teradatasql(self) -> dict[str, Any]:
         """Return set of config params required for connecting to Teradata DB 
using teradatasql client."""
         conn: Connection = self.get_connection(self.get_conn_id())
diff --git 
a/providers/src/airflow/providers/teradata/transfers/teradata_to_teradata.py 
b/providers/src/airflow/providers/teradata/transfers/teradata_to_teradata.py
index f10eb6d1004..077ce097aed 100644
--- a/providers/src/airflow/providers/teradata/transfers/teradata_to_teradata.py
+++ b/providers/src/airflow/providers/teradata/transfers/teradata_to_teradata.py
@@ -91,7 +91,7 @@ class TeradataToTeradataOperator(BaseOperator):
             rows_total = 0
             if len(target_fields) != 0:
                 for rows in iter(lambda: cursor.fetchmany(self.rows_chunk), 
[]):
-                    dest_hook.bulk_insert_rows(
+                    dest_hook.insert_rows(
                         self.destination_table,
                         rows,
                         target_fields=target_fields,
diff --git a/providers/tests/teradata/hooks/test_teradata.py 
b/providers/tests/teradata/hooks/test_teradata.py
index 21a19308b2d..f2bcb1ee269 100644
--- a/providers/tests/teradata/hooks/test_teradata.py
+++ b/providers/tests/teradata/hooks/test_teradata.py
@@ -21,9 +21,6 @@ import json
 from datetime import datetime
 from unittest import mock
 
-import pytest
-
-from airflow.exceptions import AirflowProviderDeprecationWarning
 from airflow.models import Connection
 from airflow.providers.teradata.hooks.teradata import TeradataHook, 
_handle_user_query_band_text
 
@@ -232,58 +229,6 @@ class TestTeradataHook:
             [("'test_string", None, "2023-08-15T00:00:00", "1", "3.14", 
"str")],
         )
 
-    def test_bulk_insert_rows_with_fields(self):
-        rows = [(1, 2, 3), (4, 5, 6), (7, 8, 9)]
-        target_fields = ["col1", "col2", "col3"]
-        with pytest.warns(
-            AirflowProviderDeprecationWarning,
-            match="bulk_insert_rows is deprecated. Please use the insert_rows 
method instead.",
-        ):
-            self.test_db_hook.bulk_insert_rows("table", rows, target_fields)
-        self.cur.executemany.assert_called_once_with(
-            "INSERT INTO table (col1, col2, col3) VALUES (?,?,?)",
-            [("1", "2", "3"), ("4", "5", "6"), ("7", "8", "9")],
-        )
-
-    def test_bulk_insert_rows_with_commit_every(self):
-        rows = [(1, 2, 3), (4, 5, 6), (7, 8, 9)]
-        target_fields = ["col1", "col2", "col3"]
-        with pytest.warns(
-            AirflowProviderDeprecationWarning,
-            match="bulk_insert_rows is deprecated. Please use the insert_rows 
method instead.",
-        ):
-            self.test_db_hook.bulk_insert_rows("table", rows, target_fields, 
commit_every=2)
-        calls = [
-            mock.call(
-                "INSERT INTO table (col1, col2, col3) VALUES (?,?,?)", [("1", 
"2", "3"), ("4", "5", "6")]
-            ),
-            mock.call("INSERT INTO table (col1, col2, col3) VALUES (?,?,?)", 
[("7", "8", "9")]),
-        ]
-        self.cur.executemany.assert_has_calls(calls, any_order=True)
-
-    def test_bulk_insert_rows_without_fields(self):
-        rows = [(1, 2, 3), (4, 5, 6), (7, 8, 9)]
-        with pytest.warns(
-            AirflowProviderDeprecationWarning,
-            match="bulk_insert_rows is deprecated. Please use the insert_rows 
method instead.",
-        ):
-            self.test_db_hook.bulk_insert_rows("table", rows)
-        self.cur.executemany.assert_called_once_with(
-            "INSERT INTO table  VALUES (?,?,?)",
-            [("1", "2", "3"), ("4", "5", "6"), ("7", "8", "9")],
-        )
-
-    def test_bulk_insert_rows_no_rows(self):
-        rows = []
-        with (
-            pytest.raises(ValueError),
-            pytest.warns(
-                AirflowProviderDeprecationWarning,
-                match="bulk_insert_rows is deprecated. Please use the 
insert_rows method instead.",
-            ),
-        ):
-            self.test_db_hook.bulk_insert_rows("table", rows)
-
     def test_call_proc_dict(self):
         parameters = {"a": 1, "b": 2, "c": 3}
 
diff --git a/providers/tests/teradata/transfers/test_teradata_to_teradata.py 
b/providers/tests/teradata/transfers/test_teradata_to_teradata.py
index 8f20e1f571f..023ca9e3651 100644
--- a/providers/tests/teradata/transfers/test_teradata_to_teradata.py
+++ b/providers/tests/teradata/transfers/test_teradata_to_teradata.py
@@ -109,7 +109,7 @@ class TestTeradataToTeradataTransfer:
             mock.call(rows_chunk),
         ]
         mock_cursor.fetchmany.assert_has_calls(calls)
-        mocked_dest_hook.bulk_insert_rows.assert_called_once_with(
+        mocked_dest_hook.insert_rows.assert_called_once_with(
             self.destination_table,
             cursor_rows,
             commit_every=rows_chunk,

Reply via email to