sqlparser / sqlflow_public

Document, sample code and other materials for SQLFlow
Apache License 2.0
885 stars 168 forks source link

DDL line ordering gets messed up for package body #73

Open david-valaczkai-solidatus opened 1 year ago

david-valaczkai-solidatus commented 1 year ago

Affecting Oracle:

The lines of the DDL are entangled for package body objects fetched by ingester 1.1.8 query.sql. The DDL becomes invalid and results in parsing errors and missing lineage.

Run the ingester 1.1.8 against an Oracle DB that contains packages and separate package body definitions. The separate package body objects will have invalid DDL in the metadata.

We managed to fix this by implementing this override in query.sql. We changed 'package body' type string to 'package' in SELECT, but left it as 'package body' in the WHERE condition. DDL was fine after this. The rest of query.sql is unchanged.

SELECT v.text sourceCode, -- this used to be 'package body' but it doesn't work 'package' as dbObjType, '"'||v.name||'"' as dbObjName, '"'||v.OWNER||'"."'||v.name||'"' as groupName, null as databaseName, '"'||v.OWNER||'"' as schemaName, v.line line FROM all_source v where type='PACKAGE BODY' and v.OWNER not in ('SYS', 'SYSTEM') and v.text IS NOT NULL %where_condition ORDER BY v.line

sqlparser commented 1 year ago

Thanks.

Internal link gudusoft/projects/151613/tasks/table?issue_type_category=task&issue=I63Z55