diff --git a/api/src/main/java/marquez/db/ColumnLineageDao.java b/api/src/main/java/marquez/db/ColumnLineageDao.java index 14faf16414..8225588e0d 100644 --- a/api/src/main/java/marquez/db/ColumnLineageDao.java +++ b/api/src/main/java/marquez/db/ColumnLineageDao.java @@ -185,9 +185,24 @@ SELECT DISTINCT ON (cl.output_dataset_field_uuid, cl.input_dataset_field_uuid) c ORDER BY output_dataset_field_uuid, input_dataset_field_uuid, updated_at DESC, updated_at ), dataset_fields_view AS ( - SELECT d.namespace_name as namespace_name, d.name as dataset_name, df.name as field_name, df.type, df.uuid - FROM dataset_fields df - INNER JOIN datasets_view d ON d.uuid = df.dataset_uuid + SELECT + d.namespace_name AS namespace_name, + d.name AS dataset_name, + df.name AS field_name, + df.type, + df.uuid + FROM dataset_fields df + INNER JOIN ( + SELECT uuid, namespace_name, name + FROM datasets_view + WHERE current_version_uuid IN ( + SELECT DISTINCT output_dataset_version_uuid + FROM selected_column_lineage + UNION + SELECT DISTINCT input_dataset_version_uuid + FROM selected_column_lineage + ) + ) d ON d.uuid = df.dataset_uuid ) SELECT output_fields.namespace_name,