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 22da484082a fix: use configured schema in TableauHook Server 
construction (#62847)
22da484082a is described below

commit 22da484082a6f68492da32556127760df166cae1
Author: Yoann <[email protected]>
AuthorDate: Tue Mar 10 12:32:19 2026 -0700

    fix: use configured schema in TableauHook Server construction (#62847)
    
    Previously, TableauHook.__init__ ignored the schema field from the
    connection configuration, always creating HTTP connections. Now it
    prepends the schema (e.g., https) to the host when configured.
    
    Fixes apache/airflow#62459
    
    Co-authored-by: Claude Sonnet 4.6 <[email protected]>
---
 .../src/airflow/providers/tableau/hooks/tableau.py |  3 ++-
 .../tests/unit/tableau/hooks/test_tableau.py       | 31 ++++++++++++++++++++++
 2 files changed, 33 insertions(+), 1 deletion(-)

diff --git a/providers/tableau/src/airflow/providers/tableau/hooks/tableau.py 
b/providers/tableau/src/airflow/providers/tableau/hooks/tableau.py
index 4fd083820ba..3e399278700 100644
--- a/providers/tableau/src/airflow/providers/tableau/hooks/tableau.py
+++ b/providers/tableau/src/airflow/providers/tableau/hooks/tableau.py
@@ -86,7 +86,8 @@ class TableauHook(BaseHook):
         self.tableau_conn_id = tableau_conn_id
         self.conn = self.get_connection(self.tableau_conn_id)
         self.site_id = site_id or self.conn.extra_dejson.get("site_id", "")
-        self.server = Server(self.conn.host)
+        server_address = f"{self.conn.schema}://{self.conn.host}" if 
self.conn.schema else self.conn.host
+        self.server = Server(server_address)
         verify: Any = self.conn.extra_dejson.get("verify", True)
         if isinstance(verify, str):
             verify = parse_boolean(verify)
diff --git a/providers/tableau/tests/unit/tableau/hooks/test_tableau.py 
b/providers/tableau/tests/unit/tableau/hooks/test_tableau.py
index e13642d6df9..9d5a9a18f32 100644
--- a/providers/tableau/tests/unit/tableau/hooks/test_tableau.py
+++ b/providers/tableau/tests/unit/tableau/hooks/test_tableau.py
@@ -110,6 +110,17 @@ class TestTableauHook:
                 extra='{"auth": "jwt", "jwt_token": "fake_jwt_token", 
"site_id": ""}',
             )
         )
+        create_connection_without_db(
+            models.Connection(
+                conn_id="tableau_test_with_schema",
+                conn_type="tableau",
+                host="tableau",
+                schema="https",
+                login="user",
+                password="password",
+                extra='{"site_id": "my_site"}',
+            )
+        )
 
     @patch("airflow.providers.tableau.hooks.tableau.TableauAuth")
     @patch("airflow.providers.tableau.hooks.tableau.Server")
@@ -327,6 +338,26 @@ class TestTableauHook:
             
mock_server.return_value.auth.sign_in.assert_called_once_with(mock_tableau_auth.return_value)
         mock_server.return_value.auth.sign_out.assert_called_once_with()
 
+    @patch("airflow.providers.tableau.hooks.tableau.TableauAuth")
+    @patch("airflow.providers.tableau.hooks.tableau.Server")
+    def test_get_conn_uses_schema_when_configured(self, mock_server, 
mock_tableau_auth):
+        """
+        Test that Server is constructed with the schema prepended to the host 
when schema is configured.
+        """
+        with TableauHook(tableau_conn_id="tableau_test_with_schema") as 
tableau_hook:
+            
mock_server.assert_called_once_with(f"{tableau_hook.conn.schema}://{tableau_hook.conn.host}")
+        mock_server.return_value.auth.sign_out.assert_called_once_with()
+
+    @patch("airflow.providers.tableau.hooks.tableau.TableauAuth")
+    @patch("airflow.providers.tableau.hooks.tableau.Server")
+    def test_get_conn_uses_host_only_without_schema(self, mock_server, 
mock_tableau_auth):
+        """
+        Test that Server is constructed with the host only when no schema is 
configured (backward compatibility).
+        """
+        with TableauHook(tableau_conn_id="tableau_test_password") as 
tableau_hook:
+            mock_server.assert_called_once_with(tableau_hook.conn.host)
+        mock_server.return_value.auth.sign_out.assert_called_once_with()
+
     @patch("airflow.providers.tableau.hooks.tableau.TableauAuth")
     @patch("airflow.providers.tableau.hooks.tableau.Server")
     @patch("airflow.providers.tableau.hooks.tableau.Pager", return_value=[1, 
2, 3])

Reply via email to