From 60974e4ea11d1771d28d75607811a4264972951e Mon Sep 17 00:00:00 2001 From: Ayush Shah Date: Thu, 20 Mar 2025 21:02:58 +0530 Subject: [PATCH] Revert "Fixes #17660: Oracle handle quotes for lowercase columns in workflow agents (#20309)" (#20364) --- .../src/metadata/profiler/orm/converter/base.py | 14 ++++++-------- ingestion/tests/cli_e2e/test_cli_oracle.py | 17 ++++++++--------- 2 files changed, 14 insertions(+), 17 deletions(-) diff --git a/ingestion/src/metadata/profiler/orm/converter/base.py b/ingestion/src/metadata/profiler/orm/converter/base.py index 6e254894d45..b7225c358aa 100644 --- a/ingestion/src/metadata/profiler/orm/converter/base.py +++ b/ingestion/src/metadata/profiler/orm/converter/base.py @@ -31,7 +31,7 @@ Base = declarative_base() SQA_RESERVED_ATTRIBUTES = ["metadata"] -def check_case_sensitive(table_service_type, table_or_col) -> Optional[bool]: +def check_snowflake_case_sensitive(table_service_type, table_or_col) -> Optional[bool]: """Check whether column or table name are not uppercase for snowflake table. If so, then force quoting, If not return None to let engine backend handle the logic. @@ -40,10 +40,7 @@ def check_case_sensitive(table_service_type, table_or_col) -> Optional[bool]: Return: None or True """ - if table_service_type in { - databaseService.DatabaseServiceType.Snowflake, - databaseService.DatabaseServiceType.Oracle, - }: + if table_service_type == databaseService.DatabaseServiceType.Snowflake: return True if not str(table_or_col).isupper() else None return None @@ -84,10 +81,9 @@ def build_orm_col( if _quote is not None: quote = _quote else: - quote = check_if_should_quote_column_name( table_service_type - ) or check_case_sensitive(table_service_type, col.name.root) + ) or check_snowflake_case_sensitive(table_service_type, col.name.root) return sqlalchemy.Column( name=str(col.name.root), @@ -154,7 +150,9 @@ def ometa_to_sqa_orm( "__table_args__": { "schema": orm_schema_name, "extend_existing": True, # Recreates the table ORM object if it already exists. Useful for testing - "quote": check_case_sensitive(table.serviceType, table.name.root) + "quote": check_snowflake_case_sensitive( + table.serviceType, table.name.root + ) or None, }, **cols, diff --git a/ingestion/tests/cli_e2e/test_cli_oracle.py b/ingestion/tests/cli_e2e/test_cli_oracle.py index 61eecda2154..0e9d177b8c9 100644 --- a/ingestion/tests/cli_e2e/test_cli_oracle.py +++ b/ingestion/tests/cli_e2e/test_cli_oracle.py @@ -38,8 +38,7 @@ class OracleCliTest(CliCommonDB.TestSuite, SQACommonMethods): hrly_rate NUMBER(7,2) GENERATED ALWAYS AS (sal/2080), comm NUMBER(7,2), comments VARCHAR2(3277), - status VARCHAR2(10), - "col_with_quotes" VARCHAR2(10)), + status VARCHAR2(10)) TABLESPACE USERS STORAGE ( INITIAL 50K) """ @@ -49,16 +48,16 @@ class OracleCliTest(CliCommonDB.TestSuite, SQACommonMethods): insert_data_queries: List[str] = [ """ - INSERT INTO admin.admin_emp (empno, ename, ssn, job, mgr, sal, comm, comments, status, photo, "col_with_quotes") WITH names AS ( -SELECT 1, 'John Doe', 12356789, 'Manager', 121, 5200.0, 5000.0, 'Amazing', 'Active', EMPTY_BLOB(), 'test' FROM dual UNION ALL -SELECT 2, 'Jane Doe', 123467189, 'Clerk', 131, 503.0, 5000.0, 'Wow', 'Active', EMPTY_BLOB(), 'test' FROM dual UNION ALL -SELECT 3, 'Jon Doe', 123562789, 'Assistant', 141, 5000.0, 5000.0, 'Nice', 'Active', EMPTY_BLOB(), 'test' FROM dual + INSERT INTO admin.admin_emp (empno, ename, ssn, job, mgr, sal, comm, comments, status, photo) WITH names AS ( +SELECT 1, 'John Doe', 12356789, 'Manager', 121, 5200.0, 5000.0, 'Amazing', 'Active', EMPTY_BLOB() FROM dual UNION ALL +SELECT 2, 'Jane Doe', 123467189, 'Clerk', 131, 503.0, 5000.0, 'Wow', 'Active', EMPTY_BLOB() FROM dual UNION ALL +SELECT 3, 'Jon Doe', 123562789, 'Assistant', 141, 5000.0, 5000.0, 'Nice', 'Active', EMPTY_BLOB() FROM dual ) SELECT * from names """, """ -INSERT INTO admin.admin_emp (empno, ename, ssn, job, mgr, sal, comm, comments, status, photo, "col_with_quotes") WITH names AS ( -SELECT 4, 'Jon Doe', 13456789, 'Manager', 151, 5050.0, 5000.0, 'Excellent', 'Active', UTL_RAW.CAST_TO_RAW('your_binary_data'), 'test' FROM dual +INSERT INTO admin.admin_emp (empno, ename, ssn, job, mgr, sal, comm, comments, status, photo) WITH names AS ( +SELECT 4, 'Jon Doe', 13456789, 'Manager', 151, 5050.0, 5000.0, 'Excellent', 'Active', UTL_RAW.CAST_TO_RAW('your_binary_data') FROM dual ) SELECT * from names """, @@ -104,7 +103,7 @@ SELECT * from names """view was created from `CREATE VIEW xyz AS (SELECT * FROM abc)` which does not propagate column lineage """ - return 13 + return 12 def expected_lineage_node(self) -> str: return "e2e_oracle.default.admin.admin_emp_view"