diff --git a/ingestion/src/metadata/ingestion/source/database/trino/connection.py b/ingestion/src/metadata/ingestion/source/database/trino/connection.py index 245e0a4f9b3..5c9d3cae1a6 100644 --- a/ingestion/src/metadata/ingestion/source/database/trino/connection.py +++ b/ingestion/src/metadata/ingestion/source/database/trino/connection.py @@ -49,7 +49,10 @@ def get_connection_url(connection: TrinoConnection) -> str: """ url = f"{connection.scheme.value}://" if connection.username: - url += f"{quote_plus(connection.username)}" + # we need to encode twice because trino dialect internally + # url decodes the username and if there is an special char in username + # it will fail to authenticate + url += f"{quote_plus(quote_plus(connection.username))}" if ( isinstance(connection.authType, basicAuth.BasicAuth) and connection.authType.password diff --git a/ingestion/tests/unit/test_source_connection.py b/ingestion/tests/unit/test_source_connection.py index e0a867bd9e4..e2bb811e67a 100644 --- a/ingestion/tests/unit/test_source_connection.py +++ b/ingestion/tests/unit/test_source_connection.py @@ -407,7 +407,7 @@ class SourceConnectionTest(TestCase): assert expected_url == get_connection_url(trino_conn_obj) # Passing @ in username and password - expected_url = "trino://username%40444:pass%40111@localhost:443/catalog" + expected_url = "trino://username%2540444:pass%40111@localhost:443/catalog" trino_conn_obj = TrinoConnection( scheme=TrinoScheme.trino, hostPort="localhost:443",