Revert from DBA_ to ALL_ (#16030)

This commit is contained in:
Ayush Shah 2024-04-25 13:02:47 +05:30 committed by GitHub
parent 3621407642
commit 18ba585d2f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 22 additions and 22 deletions

View File

@ -38,7 +38,7 @@ from metadata.ingestion.connections.builders import (
) )
from metadata.ingestion.connections.test_connections import test_connection_db_common from metadata.ingestion.connections.test_connections import test_connection_db_common
from metadata.ingestion.ometa.ometa_api import OpenMetadata from metadata.ingestion.ometa.ometa_api import OpenMetadata
from metadata.ingestion.source.database.oracle.queries import CHECK_ACCESS_TO_DBA from metadata.ingestion.source.database.oracle.queries import CHECK_ACCESS_TO_ALL
from metadata.utils.logger import ingestion_logger from metadata.utils.logger import ingestion_logger
CX_ORACLE_LIB_VERSION = "8.3.0" CX_ORACLE_LIB_VERSION = "8.3.0"
@ -138,7 +138,7 @@ def test_connection(
of a metadata workflow or during an Automation Workflow of a metadata workflow or during an Automation Workflow
""" """
test_conn_queries = {"CheckAccess": CHECK_ACCESS_TO_DBA} test_conn_queries = {"CheckAccess": CHECK_ACCESS_TO_ALL}
test_connection_db_common( test_connection_db_common(
metadata=metadata, metadata=metadata,

View File

@ -14,51 +14,51 @@ SQL Queries used during ingestion
import textwrap import textwrap
ORACLE_DBA_TABLE_COMMENTS = textwrap.dedent( ORACLE_ALL_TABLE_COMMENTS = textwrap.dedent(
""" """
SELECT SELECT
comments table_comment, comments table_comment,
LOWER(table_name) "table_name", LOWER(table_name) "table_name",
LOWER(owner) "schema" LOWER(owner) "schema"
FROM dba_tab_comments FROM ALL_TAB_COMMENTS
where comments is not null and owner not in ('SYSTEM', 'SYS') where comments is not null and owner not in ('SYSTEM', 'SYS')
""" """
) )
ORACLE_DBA_VIEW_DEFINITIONS = textwrap.dedent( ORACLE_ALL_VIEW_DEFINITIONS = textwrap.dedent(
""" """
SELECT SELECT
LOWER(view_name) AS "view_name", LOWER(view_name) AS "view_name",
LOWER(owner) AS "schema", LOWER(owner) AS "schema",
DBMS_METADATA.GET_DDL('VIEW', view_name, owner) AS view_def DBMS_METADATA.GET_DDL('VIEW', view_name, owner) AS view_def
FROM DBA_VIEWS FROM ALL_VIEWS
WHERE owner NOT IN ('SYSTEM', 'SYS') WHERE owner NOT IN ('SYSTEM', 'SYS')
UNION ALL UNION ALL
SELECT SELECT
LOWER(mview_name) AS "view_name", LOWER(mview_name) AS "view_name",
LOWER(owner) AS "schema", LOWER(owner) AS "schema",
DBMS_METADATA.GET_DDL('MATERIALIZED_VIEW', mview_name, owner) AS view_def DBMS_METADATA.GET_DDL('MATERIALIZED_VIEW', mview_name, owner) AS view_def
FROM DBA_MVIEWS FROM ALL_MVIEWS
WHERE owner NOT IN ('SYSTEM', 'SYS') WHERE owner NOT IN ('SYSTEM', 'SYS')
""" """
) )
GET_MATERIALIZED_VIEW_NAMES = textwrap.dedent( GET_MATERIALIZED_VIEW_NAMES = textwrap.dedent(
""" """
SELECT mview_name FROM DBA_MVIEWS WHERE owner = :owner SELECT mview_name FROM ALL_MVIEWS WHERE owner = :owner
""" """
) )
ORACLE_GET_TABLE_NAMES = textwrap.dedent( ORACLE_GET_TABLE_NAMES = textwrap.dedent(
""" """
SELECT table_name FROM DBA_TABLES WHERE SELECT table_name FROM ALL_TABLES WHERE
{tablespace} {tablespace}
OWNER = :owner OWNER = :owner
AND IOT_NAME IS NULL AND IOT_NAME IS NULL
AND DURATION IS NULL AND DURATION IS NULL
AND TABLE_NAME NOT IN AND TABLE_NAME NOT IN
(SELECT mview_name FROM DBA_MVIEWS WHERE owner = :owner) (SELECT mview_name FROM ALL_MVIEWS WHERE owner = :owner)
""" """
) )
@ -67,7 +67,7 @@ ORACLE_IDENTITY_TYPE = textwrap.dedent(
col.default_on_null, col.default_on_null,
( (
SELECT id.generation_type || ',' || id.IDENTITY_OPTIONS SELECT id.generation_type || ',' || id.IDENTITY_OPTIONS
FROM DBA_TAB_IDENTITY_COLS{dblink} id FROM ALL_TAB_IDENTITY_COLS{dblink} id
WHERE col.table_name = id.table_name WHERE col.table_name = id.table_name
AND col.column_name = id.column_name AND col.column_name = id.column_name
AND col.owner = id.owner AND col.owner = id.owner
@ -83,12 +83,12 @@ SELECT
LINE, LINE,
TEXT TEXT
FROM FROM
DBA_SOURCE ALL_SOURCE
WHERE WHERE
type = 'PROCEDURE' and owner = '{schema}' type = 'PROCEDURE' and owner = '{schema}'
""" """
) )
CHECK_ACCESS_TO_DBA = "SELECT table_name FROM DBA_TABLES where ROWNUM < 2" CHECK_ACCESS_TO_ALL = "SELECT table_name FROM ALL_TABLES where ROWNUM < 2"
ORACLE_GET_STORED_PROCEDURE_QUERIES = textwrap.dedent( ORACLE_GET_STORED_PROCEDURE_QUERIES = textwrap.dedent(
""" """
WITH SP_HISTORY AS (SELECT WITH SP_HISTORY AS (SELECT
@ -152,8 +152,8 @@ ORACLE_GET_COLUMNS = textwrap.dedent(
com.comments, com.comments,
col.virtual_column, col.virtual_column,
{identity_cols} {identity_cols}
FROM DBA_TAB_COLS{dblink} col FROM ALL_TAB_COLS{dblink} col
LEFT JOIN dba_col_comments{dblink} com LEFT JOIN ALL_COL_COMMENTS{dblink} com
ON col.table_name = com.table_name ON col.table_name = com.table_name
AND col.column_name = com.column_name AND col.column_name = com.column_name
AND col.owner = com.owner AND col.owner = com.owner

View File

@ -21,8 +21,8 @@ from sqlalchemy.sql import sqltypes
from metadata.ingestion.source.database.oracle.queries import ( from metadata.ingestion.source.database.oracle.queries import (
GET_MATERIALIZED_VIEW_NAMES, GET_MATERIALIZED_VIEW_NAMES,
ORACLE_DBA_TABLE_COMMENTS, ORACLE_ALL_TABLE_COMMENTS,
ORACLE_DBA_VIEW_DEFINITIONS, ORACLE_ALL_VIEW_DEFINITIONS,
ORACLE_GET_COLUMNS, ORACLE_GET_COLUMNS,
ORACLE_GET_TABLE_NAMES, ORACLE_GET_TABLE_NAMES,
ORACLE_IDENTITY_TYPE, ORACLE_IDENTITY_TYPE,
@ -48,7 +48,7 @@ def get_table_comment(
connection, connection,
table_name=table_name.lower(), table_name=table_name.lower(),
schema=schema.lower() if schema else None, schema=schema.lower() if schema else None,
query=ORACLE_DBA_TABLE_COMMENTS, query=ORACLE_ALL_TABLE_COMMENTS,
) )
@ -67,7 +67,7 @@ def get_view_definition(
connection, connection,
table_name=view_name.lower(), table_name=view_name.lower(),
schema=schema.lower() if schema else None, schema=schema.lower() if schema else None,
query=ORACLE_DBA_VIEW_DEFINITIONS, query=ORACLE_ALL_VIEW_DEFINITIONS,
) )

View File

@ -194,7 +194,7 @@ class OracleTableMetricComputer(BaseTableMetricComputer):
Column("object_name").label("table_name"), Column("object_name").label("table_name"),
Column("created"), Column("created"),
], ],
self._build_table("dba_objects", None), self._build_table("all_objects", None),
[ [
func.lower(Column("owner")) == self.schema_name.lower(), func.lower(Column("owner")) == self.schema_name.lower(),
func.lower(Column("object_name")) == self.table_name.lower(), func.lower(Column("object_name")) == self.table_name.lower(),
@ -209,7 +209,7 @@ class OracleTableMetricComputer(BaseTableMetricComputer):
Column("table_name"), Column("table_name"),
Column("NUM_ROWS"), Column("NUM_ROWS"),
], ],
self._build_table("dba_tables", None), self._build_table("all_tables", None),
[ [
func.lower(Column("owner")) == self.schema_name.lower(), func.lower(Column("owner")) == self.schema_name.lower(),
func.lower(Column("table_name")) == self.table_name.lower(), func.lower(Column("table_name")) == self.table_name.lower(),

View File

@ -34,7 +34,7 @@ GRANT SELECT ON table_name TO {user | role};
``` ```
### Profiler & Data Quality ### Profiler & Data Quality
Executing the profiler Workflow or data quality tests, will require the user to have `SELECT` permission on the tables/schemas where the profiler/tests will be executed. The user should also be allowed to view information in `dba_objects` and `all_tables` for all objects in the database. More information on the profiler workflow setup can be found [here](https://docs.open-metadata.org/connectors/ingestion/workflows/profiler) and data quality tests [here](https://docs.open-metadata.org/connectors/ingestion/workflows/data-quality). Executing the profiler Workflow or data quality tests, will require the user to have `SELECT` permission on the tables/schemas where the profiler/tests will be executed. The user should also be allowed to view information in `all_objects` and `all_tables` for all objects in the database. More information on the profiler workflow setup can be found [here](https://docs.open-metadata.org/connectors/ingestion/workflows/profiler) and data quality tests [here](https://docs.open-metadata.org/connectors/ingestion/workflows/data-quality).
### Usage & Lineage ### Usage & Lineage
For the usage and lineage workflow, the user will need `SELECT` privilege. You can find more information on the usage workflow [here](https://docs.open-metadata.org/connectors/ingestion/workflows/usage) and the lineage workflow [here](https://docs.open-metadata.org/connectors/ingestion/workflows/lineage). For the usage and lineage workflow, the user will need `SELECT` privilege. You can find more information on the usage workflow [here](https://docs.open-metadata.org/connectors/ingestion/workflows/usage) and the lineage workflow [here](https://docs.open-metadata.org/connectors/ingestion/workflows/lineage).