diff --git a/airflow/providers/common/sql/hooks/sql.py b/airflow/providers/common/sql/hooks/sql.py index 84a693a9d49fe5..0116d497837c03 100644 --- a/airflow/providers/common/sql/hooks/sql.py +++ b/airflow/providers/common/sql/hooks/sql.py @@ -545,7 +545,16 @@ def insert_rows( :param commit_every: The maximum number of rows to insert in one transaction. Set to 0 to insert all rows in one transaction. :param replace: Whether to replace instead of insert + :param executemany: Deprecated. It will be removed in future Airflow versions as inserts are always + executed using the executemany method. """ + if kwargs.get("executemany"): + warnings.warn( + "executemany parameter is deprecated, as executemany will always be used to insert rows.", + AirflowProviderDeprecationWarning, + stacklevel=2, + ) + with closing(self.get_conn()) as conn: if self.supports_autocommit: self.set_autocommit(conn, False) diff --git a/tests/deprecations_ignore.yml b/tests/deprecations_ignore.yml index d9553f784ff8b2..a6fadc8f0d4c1d 100644 --- a/tests/deprecations_ignore.yml +++ b/tests/deprecations_ignore.yml @@ -663,6 +663,7 @@ - tests/providers/cncf/kubernetes/test_pod_generator.py::TestPodGenerator::test_pod_name_confirm_to_max_length - tests/providers/cncf/kubernetes/test_pod_generator.py::TestPodGenerator::test_pod_name_is_valid - tests/providers/cncf/kubernetes/test_template_rendering.py::test_render_k8s_pod_yaml +- tests/providers/common/sql/hooks/test_dbapi.py::TestDbApiHook::test_insert_rows_replace_executemany_hana_dialect - tests/providers/common/sql/hooks/test_dbapi.py::TestDbApiHook::test_instance_check_works_for_legacy_db_api_hook - tests/providers/common/sql/operators/test_sql.py::TestSQLCheckOperatorDbHook::test_get_hook - tests/providers/common/sql/operators/test_sql.py::TestSqlBranch::test_branch_false_with_dag_run diff --git a/tests/providers/common/sql/hooks/test_dbapi.py b/tests/providers/common/sql/hooks/test_dbapi.py index af4611485df894..cf2751f0f9a143 100644 --- a/tests/providers/common/sql/hooks/test_dbapi.py +++ b/tests/providers/common/sql/hooks/test_dbapi.py @@ -166,7 +166,7 @@ def test_insert_rows_replace_executemany_hana_dialect(self): table = "table" rows = [("hello",), ("world",)] - self.db_hook.insert_rows(table, rows, replace=True) + self.db_hook.insert_rows(table, rows, replace=True, executemany=True) assert self.conn.close.call_count == 1 assert self.cur.close.call_count == 1