fix(ingest/adf): recurse into ForEach/IfCondition/Until container activities for lineage extraction

Merged
BR
1mo ago
+818-2

Summary

  • Root Cause: _process_pipelines() only iterated top-level pipeline activities. Container activity types (ForEach, IfCondition, Until, Switch) got a DataJob node but their nested activities list was never visited — so any CopyActivity/LookupActivity nested inside a ForEach produced no lineage edges.
  • Second issue: _extract_activity_inputs() had no handling for LookupActivity, which exposes its dataset via typeProperties.dataset.referenceName rather than the inputs attribute used by CopyActivity.

What changed:

  • Added recursive (BFS) processing: when activity.type is ForEach or Until, recurse into activity.activities; for IfCondition, recurse into both if_true_activities and if_false_activities; for Switch, recurse into each case's activities plus default_activities.
  • Added LookupActivity input extraction via dataset.reference_name.
  • Regenerated adf_foreach_golden.json and adf_branching_golden.json — both now include the previously-invisible inner DataJob nodes and their lineage edges.

Before: A Databricks → ForEach[Copy] → MSSQL pipeline showed no lineage (the CopyActivity inside ForEach was never processed)
After: CopyTableToStaging DataJob is emitted with full input/output lineage

Test plan

  • test_adf_source.py: 14/14 passed
  • test_complex_pipelines.py: 13/13 passed
  • adf_foreach_golden.json and adf_branching_golden.json updated to reflect new lineage emissions
  • ./gradlew :metadata-ingestion:lintFix — clean, no additional changes

Checklist

  • The PR conforms to DataHub's Contributing Guideline (PR Title Format)
  • Tests for the changes have been added/updated
  • Docs related to the changes have been added/updated (not applicable — internal bug fix, no user-facing config/behavior change beyond corrected lineage)

🤖 Generated with Claude Code


Summary by cubic

Fixes Azure Data Factory lineage extraction so Copy and Lookup activities nested inside container activities (ForEach, IfCondition, Until, Switch) now emit DataJob nodes with lineage edges. Previously only top-level pipeline activities were processed, so nested activities produced no lineage.

  • Traverses activities with a deque BFS and a visited-set guard, so malformed or self-referencing pipeline definitions can't loop forever.
  • Extracts Lookup inputs from dataset.reference_name instead of the inputs attribute used by Copy activities.
  • Regenerates adf_foreach_golden.json and adf_branching_golden.json to include the previously missing inner DataJobs and an unrelated upstream browsePathsV2 URN change picked up on rebase.