Fix #18177: Fix Hive Metastore connection issue (#18178)

This commit is contained in:
Mayur Singal 2024-10-09 15:04:41 +05:30 committed by GitHub
parent 675a93c61d
commit e21843b752
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -18,7 +18,7 @@ from functools import singledispatch
from typing import Any, Optional from typing import Any, Optional
from urllib.parse import quote_plus from urllib.parse import quote_plus
from pydantic import SecretStr from pydantic import SecretStr, ValidationError
from sqlalchemy.engine import Engine from sqlalchemy.engine import Engine
from metadata.generated.schema.entity.automations.workflow import ( from metadata.generated.schema.entity.automations.workflow import (
@ -187,7 +187,22 @@ def test_connection(
of a metadata workflow or during an Automation Workflow 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) engine = get_metastore_connection(service_connection.metastoreConnection)
test_connection_db_schema_sources( test_connection_db_schema_sources(