diff --git a/.changes/unreleased/Fixes-20220926-112857.yaml b/.changes/unreleased/Fixes-20220926-112857.yaml new file mode 100644 index 000000000..2a18f13ac --- /dev/null +++ b/.changes/unreleased/Fixes-20220926-112857.yaml @@ -0,0 +1,7 @@ +kind: Fixes +body: Password doesn't pass to server using LDAP connection via thrift (#310) +time: 2022-09-26T11:28:57.306285-04:00 +custom: + Author: VShkaberda + Issue: "310" + PR: "396" diff --git a/dbt/adapters/spark/connections.py b/dbt/adapters/spark/connections.py index 951e8ed70..66ca93d30 100644 --- a/dbt/adapters/spark/connections.py +++ b/dbt/adapters/spark/connections.py @@ -65,6 +65,7 @@ class SparkCredentials(Credentials): endpoint: Optional[str] = None token: Optional[str] = None user: Optional[str] = None + password: Optional[str] = None port: int = 443 auth: Optional[str] = None kerberos_service_name: Optional[str] = None @@ -375,6 +376,7 @@ def open(cls, connection): username=creds.user, auth=creds.auth, kerberos_service_name=creds.kerberos_service_name, + password=creds.password, ) conn = hive.connect(thrift_transport=transport) else: @@ -384,6 +386,7 @@ def open(cls, connection): username=creds.user, auth=creds.auth, kerberos_service_name=creds.kerberos_service_name, + password=creds.password, ) # noqa handle = PyhiveConnectionWrapper(conn) elif creds.method == SparkConnectionMethod.ODBC: diff --git a/tests/unit/test_adapter.py b/tests/unit/test_adapter.py index f87a89b2b..53b95f731 100644 --- a/tests/unit/test_adapter.py +++ b/tests/unit/test_adapter.py @@ -154,12 +154,13 @@ def test_thrift_connection(self): config = self._get_target_thrift(self.project_cfg) adapter = SparkAdapter(config) - def hive_thrift_connect(host, port, username, auth, kerberos_service_name): + def hive_thrift_connect(host, port, username, auth, kerberos_service_name, password): self.assertEqual(host, 'myorg.sparkhost.com') self.assertEqual(port, 10001) self.assertEqual(username, 'dbt') self.assertIsNone(auth) self.assertIsNone(kerberos_service_name) + self.assertIsNone(password) with mock.patch.object(hive, 'connect', new=hive_thrift_connect): connection = adapter.acquire_connection('dummy') @@ -193,12 +194,13 @@ def test_thrift_connection_kerberos(self): config = self._get_target_thrift_kerberos(self.project_cfg) adapter = SparkAdapter(config) - def hive_thrift_connect(host, port, username, auth, kerberos_service_name): + def hive_thrift_connect(host, port, username, auth, kerberos_service_name, password): self.assertEqual(host, 'myorg.sparkhost.com') self.assertEqual(port, 10001) self.assertEqual(username, 'dbt') self.assertEqual(auth, 'KERBEROS') self.assertEqual(kerberos_service_name, 'hive') + self.assertIsNone(password) with mock.patch.object(hive, 'connect', new=hive_thrift_connect): connection = adapter.acquire_connection('dummy')