Revert "Fixes #17660: Oracle handle quotes for lowercase columns in workflow agents (#20309)" (#20364)

This commit is contained in:
Ayush Shah 2025-03-20 21:02:58 +05:30 committed by GitHub
parent 5c0f1a6777
commit 60974e4ea1
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 14 additions and 17 deletions

View File

@ -31,7 +31,7 @@ Base = declarative_base()
SQA_RESERVED_ATTRIBUTES = ["metadata"] 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. """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. 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: Return:
None or True None or True
""" """
if table_service_type in { if table_service_type == databaseService.DatabaseServiceType.Snowflake:
databaseService.DatabaseServiceType.Snowflake,
databaseService.DatabaseServiceType.Oracle,
}:
return True if not str(table_or_col).isupper() else None return True if not str(table_or_col).isupper() else None
return None return None
@ -84,10 +81,9 @@ def build_orm_col(
if _quote is not None: if _quote is not None:
quote = _quote quote = _quote
else: else:
quote = check_if_should_quote_column_name( quote = check_if_should_quote_column_name(
table_service_type 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( return sqlalchemy.Column(
name=str(col.name.root), name=str(col.name.root),
@ -154,7 +150,9 @@ def ometa_to_sqa_orm(
"__table_args__": { "__table_args__": {
"schema": orm_schema_name, "schema": orm_schema_name,
"extend_existing": True, # Recreates the table ORM object if it already exists. Useful for testing "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, or None,
}, },
**cols, **cols,

View File

@ -38,8 +38,7 @@ class OracleCliTest(CliCommonDB.TestSuite, SQACommonMethods):
hrly_rate NUMBER(7,2) GENERATED ALWAYS AS (sal/2080), hrly_rate NUMBER(7,2) GENERATED ALWAYS AS (sal/2080),
comm NUMBER(7,2), comm NUMBER(7,2),
comments VARCHAR2(3277), comments VARCHAR2(3277),
status VARCHAR2(10), status VARCHAR2(10))
"col_with_quotes" VARCHAR2(10)),
TABLESPACE USERS TABLESPACE USERS
STORAGE ( INITIAL 50K) STORAGE ( INITIAL 50K)
""" """
@ -49,16 +48,16 @@ class OracleCliTest(CliCommonDB.TestSuite, SQACommonMethods):
insert_data_queries: List[str] = [ 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 ( 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(), 'test' FROM dual UNION ALL 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(), 'test' 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(), 'test' FROM dual SELECT 3, 'Jon Doe', 123562789, 'Assistant', 141, 5000.0, 5000.0, 'Nice', 'Active', EMPTY_BLOB() FROM dual
) )
SELECT * from names SELECT * from names
""", """,
""" """
INSERT INTO admin.admin_emp (empno, ename, ssn, job, mgr, sal, comm, comments, status, photo, "col_with_quotes") WITH names AS ( 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'), 'test' FROM dual 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 SELECT * from names
""", """,
@ -104,7 +103,7 @@ SELECT * from names
"""view was created from `CREATE VIEW xyz AS (SELECT * FROM abc)` """view was created from `CREATE VIEW xyz AS (SELECT * FROM abc)`
which does not propagate column lineage which does not propagate column lineage
""" """
return 13 return 12
def expected_lineage_node(self) -> str: def expected_lineage_node(self) -> str:
return "e2e_oracle.default.admin.admin_emp_view" return "e2e_oracle.default.admin.admin_emp_view"