mirror of
https://github.com/open-metadata/OpenMetadata.git
synced 2025-10-27 16:55:06 +00:00
This commit is contained in:
parent
e4c10bc401
commit
20ab64d1f1
@ -31,7 +31,7 @@ Base = declarative_base()
|
|||||||
SQA_RESERVED_ATTRIBUTES = ["metadata"]
|
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.
|
"""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,7 +40,10 @@ def check_snowflake_case_sensitive(table_service_type, table_or_col) -> Optional
|
|||||||
Return:
|
Return:
|
||||||
None or True
|
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 True if not str(table_or_col).isupper() else None
|
||||||
|
|
||||||
return None
|
return None
|
||||||
@ -81,9 +84,10 @@ 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_snowflake_case_sensitive(table_service_type, col.name.root)
|
) or check_case_sensitive(table_service_type, col.name.root)
|
||||||
|
|
||||||
return sqlalchemy.Column(
|
return sqlalchemy.Column(
|
||||||
name=str(col.name.root),
|
name=str(col.name.root),
|
||||||
@ -150,9 +154,7 @@ 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_snowflake_case_sensitive(
|
"quote": check_case_sensitive(table.serviceType, table.name.root)
|
||||||
table.serviceType, table.name.root
|
|
||||||
)
|
|
||||||
or None,
|
or None,
|
||||||
},
|
},
|
||||||
**cols,
|
**cols,
|
||||||
|
|||||||
@ -38,7 +38,8 @@ 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)
|
||||||
"""
|
"""
|
||||||
@ -48,16 +49,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) WITH names AS (
|
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() FROM dual UNION ALL
|
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() 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() FROM dual
|
SELECT 3, 'Jon Doe', 123562789, 'Assistant', 141, 5000.0, 5000.0, 'Nice', 'Active', EMPTY_BLOB(), 'test' FROM dual
|
||||||
)
|
)
|
||||||
SELECT * from names
|
SELECT * from names
|
||||||
""",
|
""",
|
||||||
"""
|
"""
|
||||||
INSERT INTO admin.admin_emp (empno, ename, ssn, job, mgr, sal, comm, comments, status, photo) WITH names AS (
|
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') FROM dual
|
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
|
SELECT * from names
|
||||||
""",
|
""",
|
||||||
@ -103,7 +104,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 12
|
return 13
|
||||||
|
|
||||||
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"
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user