From cd43f1fdcf4103f205864a721e8747f38502051d Mon Sep 17 00:00:00 2001 From: Milan Bariya <52292922+MilanBariya@users.noreply.github.com> Date: Wed, 5 Oct 2022 15:31:13 +0530 Subject: [PATCH] Fix: connector for hive has double dash (#7953) --- .../src/metadata/utils/source_connections.py | 3 --- ingestion/tests/unit/test_source_connection.py | 17 +++++++++++++++++ 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/ingestion/src/metadata/utils/source_connections.py b/ingestion/src/metadata/utils/source_connections.py index 5c4908645a6..b1c498755e3 100644 --- a/ingestion/src/metadata/utils/source_connections.py +++ b/ingestion/src/metadata/utils/source_connections.py @@ -340,9 +340,6 @@ def _(connection: HiveConnection): ) if options: - if not connection.databaseSchema: - url += "/" - url += "/" params = "&".join( f"{key}={quote_plus(value)}" for (key, value) in options.items() if value ) diff --git a/ingestion/tests/unit/test_source_connection.py b/ingestion/tests/unit/test_source_connection.py index 02bcda73275..902c2b424bc 100644 --- a/ingestion/tests/unit/test_source_connection.py +++ b/ingestion/tests/unit/test_source_connection.py @@ -143,6 +143,23 @@ class SouceConnectionTest(TestCase): ) assert expected_result == get_connection_url(hive_conn_obj) + def test_hive_url_conn_options_with_db(self): + expected_result = "hive://localhost:10000/test_db?Key=Value" + hive_conn_obj = HiveConnection( + hostPort="localhost:10000", + databaseSchema="test_db", + connectionOptions={"Key": "Value"}, + ) + assert expected_result == get_connection_url(hive_conn_obj) + + def test_hive_url_conn_options_without_db(self): + expected_result = "hive://localhost:10000?Key=Value" + hive_conn_obj = HiveConnection( + hostPort="localhost:10000", + connectionOptions={"Key": "Value"}, + ) + assert expected_result == get_connection_url(hive_conn_obj) + def test_hive_url_with_kerberos_auth(self): expected_result = "hive://localhost:10000" hive_conn_obj = HiveConnection(