fix(ingest/adf): recurse into ForEach/IfCondition/Until container activities for lineage extraction
Merged
BR
1mo ago+818+818+012345678901234567890123456789-2-2-0123456789
Summary
- Root Cause:
_process_pipelines()only iterated top-level pipeline activities. Container activity types (ForEach,IfCondition,Until,Switch) got a DataJob node but their nestedactivitieslist was never visited — so anyCopyActivity/LookupActivitynested inside aForEachproduced no lineage edges. - Second issue:
_extract_activity_inputs()had no handling forLookupActivity, which exposes its dataset viatypeProperties.dataset.referenceNamerather than theinputsattribute used byCopyActivity.
What changed:
- Added recursive (BFS) processing: when
activity.typeisForEachorUntil, recurse intoactivity.activities; forIfCondition, recurse into bothif_true_activitiesandif_false_activities; forSwitch, recurse into each case'sactivitiesplusdefault_activities. - Added
LookupActivityinput extraction viadataset.reference_name. - Regenerated
adf_foreach_golden.jsonandadf_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.jsonandadf_branching_golden.jsonupdated 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
dequeBFS and a visited-set guard, so malformed or self-referencing pipeline definitions can't loop forever. - Extracts Lookup inputs from
dataset.reference_nameinstead of theinputsattribute used by Copy activities. - Regenerates
adf_foreach_golden.jsonandadf_branching_golden.jsonto include the previously missing inner DataJobs and an unrelated upstreambrowsePathsV2URN change picked up on rebase.