mirror of
https://github.com/open-metadata/OpenMetadata.git
synced 2025-12-11 07:16:38 +00:00
Fixes: Oracle Stored Packages Test Connection Step #23370
This commit is contained in:
parent
131764db6b
commit
11a719e611
@ -48,8 +48,7 @@ from metadata.ingestion.connections.test_connections import test_connection_db_c
|
|||||||
from metadata.ingestion.ometa.ometa_api import OpenMetadata
|
from metadata.ingestion.ometa.ometa_api import OpenMetadata
|
||||||
from metadata.ingestion.source.database.oracle.queries import (
|
from metadata.ingestion.source.database.oracle.queries import (
|
||||||
CHECK_ACCESS_TO_ALL,
|
CHECK_ACCESS_TO_ALL,
|
||||||
ORACLE_GET_SCHEMA,
|
TEST_ORACLE_GET_STORED_PACKAGES,
|
||||||
ORACLE_GET_STORED_PACKAGES,
|
|
||||||
)
|
)
|
||||||
from metadata.utils.constants import THREE_MIN
|
from metadata.utils.constants import THREE_MIN
|
||||||
from metadata.utils.logger import ingestion_logger
|
from metadata.utils.logger import ingestion_logger
|
||||||
@ -97,18 +96,9 @@ class OracleConnection(BaseConnection[OracleConnectionConfig, Engine]):
|
|||||||
of a metadata workflow or during an Automation Workflow
|
of a metadata workflow or during an Automation Workflow
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def test_oracle_package_access(engine):
|
|
||||||
try:
|
|
||||||
schema_name = engine.execute(ORACLE_GET_SCHEMA).scalar()
|
|
||||||
return ORACLE_GET_STORED_PACKAGES.format(schema=schema_name)
|
|
||||||
except Exception as e:
|
|
||||||
raise OraclePackageAccessError(
|
|
||||||
f"Failed to access Oracle stored packages: {e}"
|
|
||||||
)
|
|
||||||
|
|
||||||
test_conn_queries = {
|
test_conn_queries = {
|
||||||
"CheckAccess": CHECK_ACCESS_TO_ALL,
|
"CheckAccess": CHECK_ACCESS_TO_ALL,
|
||||||
"PackageAccess": test_oracle_package_access(self.client),
|
"PackageAccess": TEST_ORACLE_GET_STORED_PACKAGES,
|
||||||
}
|
}
|
||||||
|
|
||||||
return test_connection_db_common(
|
return test_connection_db_common(
|
||||||
@ -225,9 +215,3 @@ class OracleConnection(BaseConnection[OracleConnectionConfig, Engine]):
|
|||||||
return url
|
return url
|
||||||
|
|
||||||
raise ValueError(f"Unknown connection type {connection.oracleConnectionType}")
|
raise ValueError(f"Unknown connection type {connection.oracleConnectionType}")
|
||||||
|
|
||||||
|
|
||||||
class OraclePackageAccessError(Exception):
|
|
||||||
"""
|
|
||||||
Raised when unable to access Oracle stored packages
|
|
||||||
"""
|
|
||||||
|
|||||||
@ -95,12 +95,7 @@ WHERE
|
|||||||
type = 'PROCEDURE' and owner = '{schema}'
|
type = 'PROCEDURE' and owner = '{schema}'
|
||||||
"""
|
"""
|
||||||
)
|
)
|
||||||
ORACLE_GET_SCHEMA = """
|
|
||||||
SELECT USERNAME AS SCHEMA_NAME
|
|
||||||
FROM ALL_USERS
|
|
||||||
WHERE ROWNUM = 1
|
|
||||||
ORDER BY USERNAME
|
|
||||||
"""
|
|
||||||
ORACLE_GET_STORED_PACKAGES = textwrap.dedent(
|
ORACLE_GET_STORED_PACKAGES = textwrap.dedent(
|
||||||
"""
|
"""
|
||||||
SELECT
|
SELECT
|
||||||
@ -115,6 +110,30 @@ FROM
|
|||||||
WHERE TYPE IN ('PACKAGE', 'PACKAGE BODY') AND owner = '{schema}'
|
WHERE TYPE IN ('PACKAGE', 'PACKAGE BODY') AND owner = '{schema}'
|
||||||
"""
|
"""
|
||||||
)
|
)
|
||||||
|
|
||||||
|
TEST_ORACLE_GET_STORED_PACKAGES = textwrap.dedent(
|
||||||
|
"""
|
||||||
|
SELECT
|
||||||
|
OWNER,
|
||||||
|
NAME,
|
||||||
|
LINE,
|
||||||
|
TEXT,
|
||||||
|
'StoredPackage' as procedure_type
|
||||||
|
FROM
|
||||||
|
DBA_SOURCE
|
||||||
|
WHERE
|
||||||
|
TYPE IN ('PACKAGE', 'PACKAGE BODY')
|
||||||
|
AND owner = (
|
||||||
|
SELECT
|
||||||
|
USERNAME
|
||||||
|
FROM
|
||||||
|
ALL_USERS
|
||||||
|
WHERE
|
||||||
|
ROWNUM = 1
|
||||||
|
)
|
||||||
|
"""
|
||||||
|
)
|
||||||
|
|
||||||
CHECK_ACCESS_TO_ALL = "SELECT table_name FROM DBA_TABLES where ROWNUM < 2"
|
CHECK_ACCESS_TO_ALL = "SELECT table_name FROM DBA_TABLES where ROWNUM < 2"
|
||||||
ORACLE_GET_STORED_PROCEDURE_QUERIES = textwrap.dedent(
|
ORACLE_GET_STORED_PROCEDURE_QUERIES = textwrap.dedent(
|
||||||
"""
|
"""
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user