From 070adba95b8be0c176ca101dfe731d4c8da4d783 Mon Sep 17 00:00:00 2001 From: Mayur Singal <39544459+ulixius9@users.noreply.github.com> Date: Wed, 9 Oct 2024 15:04:41 +0530 Subject: [PATCH] Fix #18177: Fix Hive Metastore connection issue (#18178) --- .../source/database/hive/connection.py | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/ingestion/src/metadata/ingestion/source/database/hive/connection.py b/ingestion/src/metadata/ingestion/source/database/hive/connection.py index 1dd20e513905..58ff134f488d 100644 --- a/ingestion/src/metadata/ingestion/source/database/hive/connection.py +++ b/ingestion/src/metadata/ingestion/source/database/hive/connection.py @@ -18,7 +18,7 @@ from typing import Any, Optional from urllib.parse import quote_plus -from pydantic import SecretStr +from pydantic import SecretStr, ValidationError from sqlalchemy.engine import Engine from metadata.generated.schema.entity.automations.workflow import ( @@ -187,7 +187,22 @@ def test_connection( of a metadata workflow or during an Automation Workflow """ - if service_connection.metastoreConnection: + if service_connection.metastoreConnection and isinstance( + service_connection.metastoreConnection, dict + ): + try: + service_connection.metastoreConnection = MysqlConnection.model_validate( + service_connection.metastoreConnection + ) + except ValidationError: + try: + service_connection.metastoreConnection = ( + PostgresConnection.model_validate( + service_connection.metastoreConnection + ) + ) + except ValidationError: + raise ValueError("Invalid metastore connection") engine = get_metastore_connection(service_connection.metastoreConnection) test_connection_db_schema_sources(