You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
SELECT DISTINCT ON (output_dataset_field_uuid, input_dataset_field_uuid) *
104
+
FROM column_lineage
105
+
ORDER BY output_dataset_field_uuid, input_dataset_field_uuid, updated_at DESC, updated_at
106
+
),
102
107
dataset_fields_view AS (
103
108
SELECT d.namespace_name as namespace_name, d.name as dataset_name, df.name as field_name, df.type, df.uuid
104
109
FROM dataset_fields df
105
110
INNER JOIN datasets_view d ON d.uuid = df.dataset_uuid
106
111
),
107
112
column_lineage_recursive AS (
108
113
(
109
-
SELECT DISTINCT ON (output_dataset_field_uuid, input_dataset_field_uuid) *, 0 as depth
110
-
FROM column_lineage
114
+
SELECT
115
+
*,
116
+
0 as depth,
117
+
false as is_cycle,
118
+
ARRAY[ROW(output_dataset_field_uuid, input_dataset_field_uuid)] as path -- path and is_cycle mechanism as describe here https://www.postgresql.org/docs/current/queries-with.html (CYCLE clause not available in postgresql 12)
119
+
FROM column_lineage_latest
111
120
WHERE output_dataset_field_uuid IN (<datasetFieldUuids>) AND created_at <= :createdAtUntil
112
-
ORDER BY output_dataset_field_uuid, input_dataset_field_uuid, updated_at DESC, updated_at
113
121
)
114
-
UNION
122
+
UNION ALL
115
123
SELECT
116
124
adjacent_node.output_dataset_version_uuid,
117
125
adjacent_node.output_dataset_field_uuid,
@@ -121,27 +129,31 @@ WHERE output_dataset_field_uuid IN (<datasetFieldUuids>) AND created_at <= :crea
121
129
adjacent_node.transformation_type,
122
130
adjacent_node.created_at,
123
131
adjacent_node.updated_at,
124
-
node.depth + 1 as depth
125
-
FROM column_lineage adjacent_node, column_lineage_recursive node
132
+
node.depth + 1 as depth,
133
+
ROW(adjacent_node.input_dataset_field_uuid, adjacent_node.output_dataset_field_uuid) = ANY(path) as is_cycle,
134
+
path || ROW(adjacent_node.input_dataset_field_uuid, adjacent_node.output_dataset_field_uuid) as path
135
+
FROM column_lineage_latest adjacent_node, column_lineage_recursive node
0 commit comments