Oracle Package ingestion error. Parsed code is incorrect.
Reopening to validate based on latest comment
ref: https://github.com/open-metadata/OpenMetadata/issues/21086#issuecomment-3888984385
Fixed in #25045 Affected module Ingestion and probably lineage
Describe the bug
When i try to open some package (in OMD) and to view code on its Code tab, i always see some kind of mess:
It seems to be, that there is some error with sorting lines of code. Some lines, that should be in the beginning could be found in the end of package.
To Reproduce Run metadata ingestion on version 170. There is a new feature, that allows to ingest packages. Run this on big package 1k+ lines.
Expected behavior DDL in OMD should look like DDL in datagrip or other ide tools.
Version:
- OpenMetadata version: 1.7.0-release
Additional context This might affect lineages with oracle packages.
Looks like there is a problem with sorting and sorting
ORDER BY
OWNER,
NAME,
LINE
should be added here
@ulixius9 Hey! Maybe it would be helpful. I think this query is ok for ORACLE_GET_STORED_PACKAGES:
SELECT
OWNER,
NAME,
LINE,
TEXT,
'StoredPackage' as procedure_type
FROM
DBA_SOURCE
WHERE TYPE IN ('PACKAGE', 'PACKAGE BODY') AND owner = '{schema}'
ORDER BY
OWNER,
NAME,
CASE type
WHEN 'PACKAGE' THEN 1
WHEN 'PACKAGE BODY' THEN 2
ELSE 3
END,
LINE
;
@AlexeySumin I tried to reproduce this, this is the dummy package that I created for testing and the same code I see on the OMD UI, can you share your package ddl to reproduce the same issue as you?
also what you recommended I cannot do that because I want procedures and functions to be part of the ingestion as well can you tell me what is the exact type which you want to ignore to fine tune it?
CREATE OR REPLACE PACKAGE BODY employee_pkg AS
PROCEDURE add_employee (
p_emp_id NUMBER,
p_name VARCHAR2,
p_salary NUMBER
) IS
BEGIN
INSERT INTO employees (emp_id, emp_name, salary)
VALUES (p_emp_id, p_name, p_salary);
COMMIT;
END add_employee;
FUNCTION get_employee_salary (
p_emp_id NUMBER
) RETURN NUMBER IS
v_salary NUMBER;
BEGIN
SELECT salary INTO v_salary
FROM employees
WHERE emp_id = p_emp_id;
RETURN v_salary;
EXCEPTION
WHEN NO_DATA_FOUND THEN
RETURN NULL;
END get_employee_salary;
END employee_pkg;
/
@ulixius9 Hey!
- I cant copy and paste it from my production, but i think, this is the package from my screenshot above: https://github.com/chameleon82/oracle-scripts/blob/master/mail_pkg.pck
- Look on the screenshot below. I dont want to ignore something, i suppose, that the problem is in missing "order by" section.
I suppose, there should be added this order by
ORDER BY
OWNER,
NAME,
CASE type
WHEN 'PACKAGE' THEN 1
WHEN 'PACKAGE BODY' THEN 2
ELSE 3
END,
LINE
;
@ulixius9 hey! any news? maybe you need some more info or test cases?
fixed by https://github.com/open-metadata/OpenMetadata/pull/25045
@ulixius9 @ayush-shah @keshavmohta09 The bug is still not fixed. Ive posted a link on package for testing in comment https://github.com/open-metadata/OpenMetadata/issues/21086#issuecomment-3180101890
You ve missed this in orded by:
CASE type
WHEN 'PACKAGE' THEN 1
WHEN 'PACKAGE BODY' THEN 2
ELSE 3
END,
Look on line numbers and code textlines, when this section is commented. Order is inciorrect.
And when i uncomment this, the code becomes correct.
We will reopen this for validation, we will share here if we can reproduce.
@AlexeySumin can you share which version are you on?
Hi @AlexeySumin, thank you for pointing out this issue. We have now fixed it in this PR: https://github.com/open-metadata/OpenMetadata/pull/25855.
@ayush-shah Im on 1.10.12 now. On every update i go and fix this sorting by hand before service is up)