diff --git a/ingestion/src/metadata/utils/source_connections.py b/ingestion/src/metadata/utils/source_connections.py index f62e52519e9..1c78a9e83d7 100644 --- a/ingestion/src/metadata/utils/source_connections.py +++ b/ingestion/src/metadata/utils/source_connections.py @@ -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 "" diff --git a/ingestion/tests/unit/test_source_connection.py b/ingestion/tests/unit/test_source_connection.py index 04a89b9ed59..24c78539bdc 100644 --- a/ingestion/tests/unit/test_source_connection.py +++ b/ingestion/tests/unit/test_source_connection.py @@ -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(