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

eladkal 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 5cc14d1fc40 Migrate `ElasticsearchSQLHook` to use `get_df` (#50454)
5cc14d1fc40 is described below

commit 5cc14d1fc401f0c269d55c9001d03909d4f78a91
Author: Guan Ming(Wesley) Chiu <[email protected]>
AuthorDate: Sun May 11 21:17:32 2025 +0800

    Migrate `ElasticsearchSQLHook` to use `get_df` (#50454)
    
    * Migrate `ElasticsearchSQLHook` to use `get_df`
    
    * Add todo comment
---
 providers/elasticsearch/README.rst                            |  2 +-
 providers/elasticsearch/pyproject.toml                        |  2 +-
 .../airflow/providers/elasticsearch/hooks/elasticsearch.py    | 11 +++++++++++
 .../tests/unit/elasticsearch/hooks/test_elasticsearch.py      |  4 ++++
 4 files changed, 17 insertions(+), 2 deletions(-)

diff --git a/providers/elasticsearch/README.rst 
b/providers/elasticsearch/README.rst
index 2d82dd50831..afbb1220156 100644
--- a/providers/elasticsearch/README.rst
+++ b/providers/elasticsearch/README.rst
@@ -54,7 +54,7 @@ Requirements
 PIP package                              Version required
 =======================================  ==================
 ``apache-airflow``                       ``>=2.10.0``
-``apache-airflow-providers-common-sql``  ``>=1.26.0``
+``apache-airflow-providers-common-sql``  ``>=1.27.0``
 ``elasticsearch``                        ``>=8.10,<9``
 =======================================  ==================
 
diff --git a/providers/elasticsearch/pyproject.toml 
b/providers/elasticsearch/pyproject.toml
index e2ed7865bdf..ffd760c4ba0 100644
--- a/providers/elasticsearch/pyproject.toml
+++ b/providers/elasticsearch/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.26.0",
+    "apache-airflow-providers-common-sql>=1.27.0",
     "elasticsearch>=8.10,<9",
 ]
 
diff --git 
a/providers/elasticsearch/src/airflow/providers/elasticsearch/hooks/elasticsearch.py
 
b/providers/elasticsearch/src/airflow/providers/elasticsearch/hooks/elasticsearch.py
index fde29390a37..dba66b44462 100644
--- 
a/providers/elasticsearch/src/airflow/providers/elasticsearch/hooks/elasticsearch.py
+++ 
b/providers/elasticsearch/src/airflow/providers/elasticsearch/hooks/elasticsearch.py
@@ -219,6 +219,17 @@ class ElasticsearchSQLHook(DbApiHook):
 
         return uri
 
+    def _get_polars_df(
+        self,
+        sql,
+        parameters: list | tuple | Mapping[str, Any] | None = None,
+        **kwargs,
+    ):
+        # TODO: Custom ElasticsearchSQLCursor is incompatible with 
polars.read_database.
+        # To support: either adapt cursor to polars._executor interface or 
create custom polars reader.
+        # https://github.com/apache/airflow/pull/50454
+        raise NotImplementedError("Polars is not supported for Elasticsearch")
+
 
 class ElasticsearchPythonHook(BaseHook):
     """
diff --git 
a/providers/elasticsearch/tests/unit/elasticsearch/hooks/test_elasticsearch.py 
b/providers/elasticsearch/tests/unit/elasticsearch/hooks/test_elasticsearch.py
index 9848f6ae8d7..095ed14200f 100644
--- 
a/providers/elasticsearch/tests/unit/elasticsearch/hooks/test_elasticsearch.py
+++ 
b/providers/elasticsearch/tests/unit/elasticsearch/hooks/test_elasticsearch.py
@@ -177,6 +177,10 @@ class TestElasticsearchSQLHook:
         self.spy_agency.assert_spy_called(self.cur.close)
         self.spy_agency.assert_spy_called(self.cur.execute)
 
+    def test_get_df_polars(self):
+        with pytest.raises(NotImplementedError):
+            self.db_hook.get_df("SQL", df_type="polars")
+
     def test_run(self):
         statement = "SELECT * FROM hollywood.actors"
 

Reply via email to