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

This commit is contained in:
Ayush Shah 2025-03-18 15:48:58 +05:30 committed by GitHub
parent e4c10bc401
commit 20ab64d1f1
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 17 additions and 14 deletions

View File

@ -31,7 +31,7 @@ Base = declarative_base()
SQA_RESERVED_ATTRIBUTES = ["metadata"]
def check_snowflake_case_sensitive(table_service_type, table_or_col) -> Optional[bool]:
def check_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,7 +40,10 @@ def check_snowflake_case_sensitive(table_service_type, table_or_col) -> Optional
Return:
None or True
"""
if table_service_type == databaseService.DatabaseServiceType.Snowflake:
if table_service_type in {
databaseService.DatabaseServiceType.Snowflake,
databaseService.DatabaseServiceType.Oracle,
}:
return True if not str(table_or_col).isupper() else None
return None
@ -81,9 +84,10 @@ def build_orm_col(
if _quote is not None:
quote = _quote
else:
quote = check_if_should_quote_column_name(
table_service_type
) or check_snowflake_case_sensitive(table_service_type, col.name.root)
) or check_case_sensitive(table_service_type, col.name.root)
return sqlalchemy.Column(
name=str(col.name.root),
@ -150,9 +154,7 @@ 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_snowflake_case_sensitive(
table.serviceType, table.name.root
)
"quote": check_case_sensitive(table.serviceType, table.name.root)
or None,
},
**cols,

View File

@ -38,7 +38,8 @@ 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))
status VARCHAR2(10),
"col_with_quotes" VARCHAR2(10)),
TABLESPACE USERS
STORAGE ( INITIAL 50K)
"""
@ -48,16 +49,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) 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
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
)
SELECT * from names
""",
"""
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
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
)
SELECT * from names
""",
@ -103,7 +104,7 @@ SELECT * from names
"""view was created from `CREATE VIEW xyz AS (SELECT * FROM abc)`
which does not propagate column lineage
"""
return 12
return 13
def expected_lineage_node(self) -> str:
return "e2e_oracle.default.admin.admin_emp_view"