Fix: Hive connection issue (#8583)

* Fix: Hive connection issue

* Change based on comments
This commit is contained in:
Milan Bariya 2022-11-08 20:52:37 +05:30 committed by GitHub
parent 2ffb88f6aa
commit 4d16be2608
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 27 additions and 2 deletions

View File

@ -336,12 +336,18 @@ def _(connection: HiveConnection):
and hasattr(connection.connectionArguments, "auth")
and connection.connectionArguments.auth in ("LDAP", "CUSTOM")
):
url += f"{quote_plus(connection.username)}"
url += quote_plus(connection.username)
if not connection.password:
connection.password = SecretStr("")
url += f":{quote_plus(connection.password.get_secret_value())}"
url += "@"
elif connection.username:
url += quote_plus(connection.username)
if connection.password:
url += f":{quote_plus(connection.password.get_secret_value())}"
url += "@"
url += connection.hostPort
url += f"/{connection.databaseSchema}" if connection.databaseSchema else ""

View File

@ -197,7 +197,7 @@ class SouceConnectionTest(TestCase):
assert expected_result == get_connection_url(hive_conn_obj)
def test_hive_url_without_auth(self):
expected_result = "hive://localhost:10000"
expected_result = "hive://username:password@localhost:10000"
hive_conn_obj = HiveConnection(
scheme=HiveScheme.hive.value,
username="username",
@ -207,6 +207,25 @@ class SouceConnectionTest(TestCase):
)
assert expected_result == get_connection_url(hive_conn_obj)
def test_hive_url_without_connection_arguments(self):
expected_result = "hive://username:password@localhost:10000"
hive_conn_obj = HiveConnection(
scheme=HiveScheme.hive.value,
username="username",
password="password",
hostPort="localhost:10000",
)
assert expected_result == get_connection_url(hive_conn_obj)
def test_hive_url_without_connection_arguments_pass(self):
expected_result = "hive://username@localhost:10000"
hive_conn_obj = HiveConnection(
scheme=HiveScheme.hive.value,
username="username",
hostPort="localhost:10000",
)
assert expected_result == get_connection_url(hive_conn_obj)
def test_trino_url_without_params(self):
expected_url = "trino://username:pass@localhost:443/catalog"
trino_conn_obj = TrinoConnection(