ETL Patterns¶
These examples model pipelines you would actually run in a Fabric workspace: landing ingestion, notebook transforms, scheduled gold refreshes, lakehouse-to-warehouse hand-offs, parameterized ELT controllers, and lock-guarded orchestration.
All scripts live under examples/ and print Fabric JSON (or write an item folder) when run with uv run python examples/<name>.py.
Example catalog¶
| Example | What it shows |
|---|---|
daily_notebook_transform.py |
Smallest useful flow: Wait → Notebook |
landing_truncate_copy.py |
Sql MI truncate + Copy with column mappings and library variables |
scheduled_gold_refresh.py |
Weekly schedule, pinned logical_id, save_item() Git folder export |
lakehouse_lookup_to_warehouse.py |
Lookup → SetVariable → Lakehouse-to-Warehouse Copy |
parameterized_elt_controller.py |
Parameter, ForEach, Dataflow, Switch, StoredProcedure, Fail |
etl_with_lock_pattern.py |
Lock acquire / retry / invoke child / release |
Pattern: truncate, then copy¶
examples/landing_truncate_copy.py is the classic landing load:
Scripttruncates the landing table.Copyreads a typed SQL subset from an ERP twin.TabularTranslatormaps columns explicitly.- Connections come from Fabric Variable Library entries via
LibraryVariable.
Use this when promoting UI-built landing pipelines into code without losing connector detail.
Pattern: scheduled notebook refresh¶
examples/scheduled_gold_refresh.py attaches a weekday evening schedule with weekly_at, pins logical_id so renames stay the same Fabric item, and writes:
Gold_Finance_Metrics_Refresh.DataPipeline/
pipeline-content.json
.platform
.schedules
See Scheduling for the schedule model and Exporting for save_item() / save_workspace().
Pattern: lookup watermark, then load warehouse¶
examples/lakehouse_lookup_to_warehouse.py covers the ELT hand-off:
Lookupreads the latest batch from a Lakehouse control table.SetVariablestoresbatch_idfor downstream use.Copyappends silver facts into a Fabric Warehouse table.- Pipeline
parametersandvariableskeep the graph reusable.
Pattern: parameterized ELT controller¶
examples/parameterized_elt_controller.py is a parent controller:
ForEachwalks@pipeline().parameters.tables.- Each iteration refreshes a Dataflow Gen2 item.
Switchonmoderuns a warehouse merge forfull, otherwiseFail.
This is the pattern to reach for when one pipeline should drive many similar loads.
Pattern: lock, wait, run, release¶
examples/etl_with_lock_pattern.py models a concurrency-1 sales ETL orchestrator:
- Try to acquire a lock with a
Scriptactivity. - Use
IfConditionto detect whether the lock was acquired. - If not,
Waitand retry inside anUntilloop. - Once the lock is acquired,
ExecutePipelineruns the child pipeline. - A final
Scriptreleases the lock onCompleted.
Techniques worth copying¶
- assign long expression paths to named Python constants
- separate query text into structured
ScriptBlockobjects - model retry behavior with
Untilinstead of hand-wiring repetitive dependencies - keep release and cleanup steps explicit in the graph (
on="Completed")
Where to start¶
daily_notebook_transform.py— first successful exportlanding_truncate_copy.py— first real data movementscheduled_gold_refresh.py— first Git item folder with a scheduleetl_with_lock_pattern.py— production-style orchestration