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

jscheffl 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 49ea0a2fbd9 Fix HiveServer2Hook password handling for PLAIN auth 
(#62364)
49ea0a2fbd9 is described below

commit 49ea0a2fbd9c78f057fa53ed3462f56473bd31e6
Author: Shashwati Bhattacharyaa <[email protected]>
AuthorDate: Wed Feb 25 02:48:38 2026 +0530

    Fix HiveServer2Hook password handling for PLAIN auth (#62364)
    
    Co-authored-by: Shashwati <[email protected]>
---
 .../src/airflow/providers/apache/hive/hooks/hive.py  |  4 ++--
 .../hive/tests/unit/apache/hive/hooks/test_hive.py   | 20 ++++++++++++++++++++
 2 files changed, 22 insertions(+), 2 deletions(-)

diff --git 
a/providers/apache/hive/src/airflow/providers/apache/hive/hooks/hive.py 
b/providers/apache/hive/src/airflow/providers/apache/hive/hooks/hive.py
index a9758f61bf7..20bc8677593 100644
--- a/providers/apache/hive/src/airflow/providers/apache/hive/hooks/hive.py
+++ b/providers/apache/hive/src/airflow/providers/apache/hive/hooks/hive.py
@@ -877,8 +877,8 @@ class HiveServer2Hook(DbApiHook):
             auth_mechanism = db.extra_dejson.get("auth_mechanism", "KERBEROS")
             kerberos_service_name = 
db.extra_dejson.get("kerberos_service_name", "hive")
 
-        # Password should be set if and only if in LDAP or CUSTOM mode
-        if auth_mechanism in ("LDAP", "CUSTOM"):
+        # Password should be set if in LDAP, CUSTOM or PLAIN mode
+        if auth_mechanism in ("LDAP", "CUSTOM", "PLAIN"):
             password = db.password
 
         from pyhive.hive import connect
diff --git a/providers/apache/hive/tests/unit/apache/hive/hooks/test_hive.py 
b/providers/apache/hive/tests/unit/apache/hive/hooks/test_hive.py
index f94c05c3e27..beb82a926b0 100644
--- a/providers/apache/hive/tests/unit/apache/hive/hooks/test_hive.py
+++ b/providers/apache/hive/tests/unit/apache/hive/hooks/test_hive.py
@@ -677,6 +677,26 @@ class TestHiveServer2Hook:
                 database="default",
             )
 
+    @mock.patch("pyhive.hive.connect")
+    def test_get_conn_with_password_plain(self, mock_connect):
+        conn_id = "conn_plain_with_password"
+        conn_env = CONN_ENV_PREFIX + conn_id.upper()
+
+        with mock.patch.dict(
+            "os.environ",
+            {conn_env: 
"jdbc+hive2://login:password@localhost:10000/default?auth_mechanism=PLAIN"},
+        ):
+            HiveServer2Hook(hiveserver2_conn_id=conn_id).get_conn()
+            mock_connect.assert_called_once_with(
+                host="localhost",
+                port=10000,
+                auth="PLAIN",
+                kerberos_service_name=None,
+                username="login",
+                password="password",
+                database="default",
+            )
+
     @pytest.mark.parametrize(
         ("host", "port", "schema", "message"),
         [

Reply via email to