From 18ba585d2fb3665ab66f5a075ed13c78ee971903 Mon Sep 17 00:00:00 2001 From: Ayush Shah Date: Thu, 25 Apr 2024 13:02:47 +0530 Subject: [PATCH] Revert from DBA_ to ALL_ (#16030) --- .../source/database/oracle/connection.py | 4 +-- .../source/database/oracle/queries.py | 26 +++++++++---------- .../ingestion/source/database/oracle/utils.py | 8 +++--- .../orm/functions/table_metric_computer.py | 4 +-- .../public/locales/en-US/Database/Oracle.md | 2 +- 5 files changed, 22 insertions(+), 22 deletions(-) diff --git a/ingestion/src/metadata/ingestion/source/database/oracle/connection.py b/ingestion/src/metadata/ingestion/source/database/oracle/connection.py index 324aa5def4f..ade91239645 100644 --- a/ingestion/src/metadata/ingestion/source/database/oracle/connection.py +++ b/ingestion/src/metadata/ingestion/source/database/oracle/connection.py @@ -38,7 +38,7 @@ from metadata.ingestion.connections.builders import ( ) from metadata.ingestion.connections.test_connections import test_connection_db_common 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 CX_ORACLE_LIB_VERSION = "8.3.0" @@ -138,7 +138,7 @@ def test_connection( 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( metadata=metadata, diff --git a/ingestion/src/metadata/ingestion/source/database/oracle/queries.py b/ingestion/src/metadata/ingestion/source/database/oracle/queries.py index c07f8725d65..2cddcc4bbfb 100644 --- a/ingestion/src/metadata/ingestion/source/database/oracle/queries.py +++ b/ingestion/src/metadata/ingestion/source/database/oracle/queries.py @@ -14,51 +14,51 @@ SQL Queries used during ingestion import textwrap -ORACLE_DBA_TABLE_COMMENTS = textwrap.dedent( +ORACLE_ALL_TABLE_COMMENTS = textwrap.dedent( """ SELECT comments table_comment, LOWER(table_name) "table_name", LOWER(owner) "schema" -FROM dba_tab_comments +FROM ALL_TAB_COMMENTS where comments is not null and owner not in ('SYSTEM', 'SYS') """ ) -ORACLE_DBA_VIEW_DEFINITIONS = textwrap.dedent( +ORACLE_ALL_VIEW_DEFINITIONS = textwrap.dedent( """ SELECT LOWER(view_name) AS "view_name", LOWER(owner) AS "schema", DBMS_METADATA.GET_DDL('VIEW', view_name, owner) AS view_def -FROM DBA_VIEWS +FROM ALL_VIEWS WHERE owner NOT IN ('SYSTEM', 'SYS') UNION ALL SELECT LOWER(mview_name) AS "view_name", LOWER(owner) AS "schema", DBMS_METADATA.GET_DDL('MATERIALIZED_VIEW', mview_name, owner) AS view_def -FROM DBA_MVIEWS +FROM ALL_MVIEWS WHERE owner NOT IN ('SYSTEM', 'SYS') """ ) 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( """ -SELECT table_name FROM DBA_TABLES WHERE +SELECT table_name FROM ALL_TABLES WHERE {tablespace} OWNER = :owner AND IOT_NAME IS NULL AND DURATION IS NULL 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, ( 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 AND col.column_name = id.column_name AND col.owner = id.owner @@ -83,12 +83,12 @@ SELECT LINE, TEXT FROM - DBA_SOURCE + ALL_SOURCE WHERE 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( """ WITH SP_HISTORY AS (SELECT @@ -152,8 +152,8 @@ ORACLE_GET_COLUMNS = textwrap.dedent( com.comments, col.virtual_column, {identity_cols} - FROM DBA_TAB_COLS{dblink} col - LEFT JOIN dba_col_comments{dblink} com + FROM ALL_TAB_COLS{dblink} col + LEFT JOIN ALL_COL_COMMENTS{dblink} com ON col.table_name = com.table_name AND col.column_name = com.column_name AND col.owner = com.owner diff --git a/ingestion/src/metadata/ingestion/source/database/oracle/utils.py b/ingestion/src/metadata/ingestion/source/database/oracle/utils.py index 777ec8c1d69..a44db57f834 100644 --- a/ingestion/src/metadata/ingestion/source/database/oracle/utils.py +++ b/ingestion/src/metadata/ingestion/source/database/oracle/utils.py @@ -21,8 +21,8 @@ from sqlalchemy.sql import sqltypes from metadata.ingestion.source.database.oracle.queries import ( GET_MATERIALIZED_VIEW_NAMES, - ORACLE_DBA_TABLE_COMMENTS, - ORACLE_DBA_VIEW_DEFINITIONS, + ORACLE_ALL_TABLE_COMMENTS, + ORACLE_ALL_VIEW_DEFINITIONS, ORACLE_GET_COLUMNS, ORACLE_GET_TABLE_NAMES, ORACLE_IDENTITY_TYPE, @@ -48,7 +48,7 @@ def get_table_comment( connection, table_name=table_name.lower(), 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, table_name=view_name.lower(), schema=schema.lower() if schema else None, - query=ORACLE_DBA_VIEW_DEFINITIONS, + query=ORACLE_ALL_VIEW_DEFINITIONS, ) diff --git a/ingestion/src/metadata/profiler/orm/functions/table_metric_computer.py b/ingestion/src/metadata/profiler/orm/functions/table_metric_computer.py index b5630559f12..10de8698a31 100644 --- a/ingestion/src/metadata/profiler/orm/functions/table_metric_computer.py +++ b/ingestion/src/metadata/profiler/orm/functions/table_metric_computer.py @@ -194,7 +194,7 @@ class OracleTableMetricComputer(BaseTableMetricComputer): Column("object_name").label("table_name"), 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("object_name")) == self.table_name.lower(), @@ -209,7 +209,7 @@ class OracleTableMetricComputer(BaseTableMetricComputer): Column("table_name"), 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("table_name")) == self.table_name.lower(), diff --git a/openmetadata-ui/src/main/resources/ui/public/locales/en-US/Database/Oracle.md b/openmetadata-ui/src/main/resources/ui/public/locales/en-US/Database/Oracle.md index 58d9a3e3d2c..56986ad15bf 100644 --- a/openmetadata-ui/src/main/resources/ui/public/locales/en-US/Database/Oracle.md +++ b/openmetadata-ui/src/main/resources/ui/public/locales/en-US/Database/Oracle.md @@ -34,7 +34,7 @@ GRANT SELECT ON table_name TO {user | role}; ``` ### 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 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).