You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by po...@apache.org on 2025/04/30 22:27:58 UTC

(airflow) branch main updated: Update Exasol provider dependencies and deprecate get_pandas_df method (#50017)

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

potiuk 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 c37e6eb4825 Update Exasol provider dependencies and deprecate get_pandas_df method (#50017)
c37e6eb4825 is described below

commit c37e6eb482548d913d71c3ac023b7d74c05d5b5e
Author: Guan Ming(Wesley) Chiu <10...@users.noreply.github.com>
AuthorDate: Thu May 1 06:27:52 2025 +0800

    Update Exasol provider dependencies and deprecate get_pandas_df method (#50017)
---
 providers/exasol/README.rst                        |  2 +-
 providers/exasol/pyproject.toml                    |  2 +-
 .../src/airflow/providers/exasol/hooks/exasol.py   | 32 +++++++++++++++++++++-
 .../exasol/tests/unit/exasol/hooks/test_exasol.py  | 20 ++++++++++++++
 4 files changed, 53 insertions(+), 3 deletions(-)

diff --git a/providers/exasol/README.rst b/providers/exasol/README.rst
index 70d773734a5..1bb58668c30 100644
--- a/providers/exasol/README.rst
+++ b/providers/exasol/README.rst
@@ -54,7 +54,7 @@ Requirements
 PIP package                              Version required
 =======================================  ==================
 ``apache-airflow``                       ``>=2.10.0``
-``apache-airflow-providers-common-sql``  ``>=1.21.0``
+``apache-airflow-providers-common-sql``  ``>=1.26.0``
 ``pyexasol``                             ``>=0.5.1``
 ``pandas``                               ``>=2.1.2,<2.2``
 =======================================  ==================
diff --git a/providers/exasol/pyproject.toml b/providers/exasol/pyproject.toml
index c16ef083d61..c6669e83d74 100644
--- a/providers/exasol/pyproject.toml
+++ b/providers/exasol/pyproject.toml
@@ -58,7 +58,7 @@ requires-python = "~=3.9"
 # After you modify the dependencies, and rebuild your Breeze CI image with ``breeze ci-image build``
 dependencies = [
     "apache-airflow>=2.10.0",
-    "apache-airflow-providers-common-sql>=1.21.0",
+    "apache-airflow-providers-common-sql>=1.26.0",
     "pyexasol>=0.5.1",
     # In pandas 2.2 minimal version of the sqlalchemy is 2.0
     # https://pandas.pydata.org/docs/whatsnew/v2.2.0.html#increased-minimum-versions-for-dependencies
diff --git a/providers/exasol/src/airflow/providers/exasol/hooks/exasol.py b/providers/exasol/src/airflow/providers/exasol/hooks/exasol.py
index 34ea8cbbf2f..cbd59bfb294 100644
--- a/providers/exasol/src/airflow/providers/exasol/hooks/exasol.py
+++ b/providers/exasol/src/airflow/providers/exasol/hooks/exasol.py
@@ -22,8 +22,10 @@ from contextlib import closing
 from typing import TYPE_CHECKING, Any, Callable, TypeVar, overload
 
 import pyexasol
+from deprecated import deprecated
 from pyexasol import ExaConnection, ExaStatement
 
+from airflow.exceptions import AirflowProviderDeprecationWarning
 from airflow.providers.common.sql.hooks.handlers import return_single_query_results
 from airflow.providers.common.sql.hooks.sql import DbApiHook
 
@@ -73,7 +75,7 @@ class ExasolHook(DbApiHook):
         conn = pyexasol.connect(**conn_args)
         return conn
 
-    def get_pandas_df(
+    def _get_pandas_df(
         self, sql, parameters: Iterable | Mapping[str, Any] | None = None, **kwargs
     ) -> pd.DataFrame:
         """
@@ -90,6 +92,34 @@ class ExasolHook(DbApiHook):
             df = conn.export_to_pandas(sql, query_params=parameters, **kwargs)
             return df
 
+    @deprecated(
+        reason="Replaced by function `get_df`.",
+        category=AirflowProviderDeprecationWarning,
+        action="ignore",
+    )
+    def get_pandas_df(
+        self,
+        sql,
+        parameters: list | tuple | Mapping[str, Any] | None = None,
+        **kwargs,
+    ) -> pd.DataFrame:
+        """
+        Execute the sql and returns a pandas dataframe.
+
+        :param sql: the sql statement to be executed (str) or a list of sql statements to execute
+        :param parameters: The parameters to render the SQL query with.
+        :param kwargs: (optional) passed into pandas.io.sql.read_sql method
+        """
+        return self._get_pandas_df(sql, parameters, **kwargs)
+
+    def _get_polars_df(
+        self,
+        sql,
+        parameters: list | tuple | Mapping[str, Any] | None = None,
+        **kwargs,
+    ):
+        raise NotImplementedError("Polars is not supported for Exasol")
+
     def get_records(
         self,
         sql: str | list[str],
diff --git a/providers/exasol/tests/unit/exasol/hooks/test_exasol.py b/providers/exasol/tests/unit/exasol/hooks/test_exasol.py
index 9882622aef5..580adf2b120 100644
--- a/providers/exasol/tests/unit/exasol/hooks/test_exasol.py
+++ b/providers/exasol/tests/unit/exasol/hooks/test_exasol.py
@@ -171,3 +171,23 @@ class TestExasolHook:
             query_params=query_params,
             export_params=export_params,
         )
+
+    def test_get_df_pandas(self):
+        statement = "SQL"
+        column = "col"
+        result_sets = [("row1",), ("row2",)]
+        mock_df = mock.MagicMock()
+        mock_df.columns = [column]
+        mock_df.values.tolist.return_value = result_sets
+        self.conn.export_to_pandas.return_value = mock_df
+
+        df = self.db_hook.get_df(statement, df_type="pandas")
+
+        assert column == df.columns[0]
+
+        assert result_sets[0][0] == df.values.tolist()[0][0]
+        assert result_sets[1][0] == df.values.tolist()[1][0]
+
+    def test_get_df_polars(self):
+        with pytest.raises(NotImplementedError):
+            self.db_hook.get_df("SQL", df_type="polars")