Fix #6823: Fix hive attribute error (#6824)

* Fix #6823: Fix hive attribute error

* Empty commit to start test
This commit is contained in:
Mayur Singal 2022-08-19 17:52:54 +05:30 committed by GitHub
parent 3f1fc5344a
commit 7c004a6785
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 23 additions and 9 deletions

View File

@ -317,15 +317,17 @@ def _(connection: SnowflakeConnection):
@get_connection_url.register
def _(connection: HiveConnection):
url = f"{connection.scheme.value}://"
if connection.connectionArguments:
if connection.connectionArguments.auth in ("LDAP", "CUSTOM"):
if connection.username:
url += f"{connection.username}"
if not connection.password:
connection.password = SecretStr("")
url += f":{quote_plus(connection.password.get_secret_value())}"
url += "@"
if (
connection.username
and connection.connectionArguments
and hasattr(connection.connectionArguments, "auth")
and connection.connectionArguments.auth in ("LDAP", "CUSTOM")
):
url += f"{connection.username}"
if not connection.password:
connection.password = SecretStr("")
url += f":{quote_plus(connection.password.get_secret_value())}"
url += "@"
url += connection.hostPort
url += f"/{connection.databaseSchema}" if connection.databaseSchema else ""
@ -335,6 +337,7 @@ def _(connection: HiveConnection):
if connection.connectionOptions
else connection.connectionOptions
)
if options:
if not connection.databaseSchema:
url += "/"

View File

@ -154,6 +154,17 @@ class SouceConnectionTest(TestCase):
)
assert expected_result == get_connection_url(hive_conn_obj)
def test_hive_url_without_auth(self):
expected_result = "hive://localhost:10000"
hive_conn_obj = HiveConnection(
scheme=HiveScheme.hive.value,
username="username",
password="password",
hostPort="localhost:10000",
connectionArguments={"customKey": "value"},
)
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(