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
+
WHERE created_at <= :createdAtUntil
106
+
ORDER BY output_dataset_field_uuid, input_dataset_field_uuid, updated_at DESC, updated_at
107
+
),
102
108
dataset_fields_view AS (
103
109
SELECT d.namespace_name as namespace_name, d.name as dataset_name, df.name as field_name, df.type, df.uuid
104
110
FROM dataset_fields df
105
111
INNER JOIN datasets_view d ON d.uuid = df.dataset_uuid
106
112
),
107
113
column_lineage_recursive AS (
108
114
(
109
-
SELECT DISTINCT ON (output_dataset_field_uuid, input_dataset_field_uuid) *, 0 as depth
110
-
FROM column_lineage
111
-
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
115
+
SELECT
116
+
*,
117
+
0 as depth,
118
+
false as is_cycle,
119
+
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)
120
+
FROM column_lineage_latest
121
+
WHERE output_dataset_field_uuid IN (<datasetFieldUuids>)
113
122
)
114
-
UNION
123
+
UNION ALL
115
124
SELECT
116
125
adjacent_node.output_dataset_version_uuid,
117
126
adjacent_node.output_dataset_field_uuid,
@@ -121,27 +130,31 @@ WHERE output_dataset_field_uuid IN (<datasetFieldUuids>) AND created_at <= :crea
121
130
adjacent_node.transformation_type,
122
131
adjacent_node.created_at,
123
132
adjacent_node.updated_at,
124
-
node.depth + 1 as depth
125
-
FROM column_lineage adjacent_node, column_lineage_recursive node
133
+
node.depth + 1 as depth,
134
+
ROW(adjacent_node.input_dataset_field_uuid, adjacent_node.output_dataset_field_uuid) = ANY(path) as is_cycle,
135
+
path || ROW(adjacent_node.input_dataset_field_uuid, adjacent_node.output_dataset_field_uuid) as path
136
+
FROM column_lineage_latest adjacent_node, column_lineage_recursive node
0 commit comments