The idea
A metadata-driven pipeline separates how data moves (generic, written once) from what moves (one row per table in a control table). The pipeline reads the control table, loops over the active rows, and for each one extracts, lands, logs and advances a watermark. Onboarding a new source table becomes an insert, not a deployment.
The pattern fits movement work very well: landing bronze, standard merges into silver, full reloads of small reference tables. It fits modeling work badly, which is the subject of the last section.
The control table
Keep the control table small and boring. Every column should be something the generic pipeline actually reads.
CREATE TABLE meta.load_config (
config_id int NOT NULL,
source_system varchar(50) NOT NULL, -- 'erp', 'crm', 'files'
source_object varchar(200) NOT NULL, -- 'sales_order_line'
target_layer varchar(10) NOT NULL, -- 'bronze' or 'silver'
target_table varchar(200) NOT NULL, -- 'bronze.erp_sales_order_line'
load_type varchar(12) NOT NULL, -- 'full' or 'incremental'
watermark_column varchar(128) NULL, -- 'modified_at'
last_watermark datetime2(6) NULL,
merge_keys varchar(400) NULL, -- 'order_number,line_number'
load_order int NOT NULL, -- wave number: lower loads first
is_active bit NOT NULL
);
ALTER TABLE meta.load_config
ADD CONSTRAINT pk_load_config PRIMARY KEY NONCLUSTERED (config_id) NOT ENFORCED;
Fabric Warehouse uses varchar (with UTF-8 collations) rather than nvarchar, caps datetime2 at precision 6, and accepts primary keys only as NONCLUSTERED ... NOT ENFORCED, so uniqueness of config_id is your job. For the sample model the rows look like this:
| source_system | source_object | load_type | watermark_column | merge_keys | load_order |
|---|---|---|---|---|---|
| erp | customer | incremental | modified_at | customer_id | 10 |
| erp | product | full | product_id | 10 | |
| erp | warehouse | full | warehouse_id | 10 | |
| crm | salesperson | full | salesperson_id | 10 | |
| erp | sales_order_header | incremental | modified_at | order_number | 20 |
| erp | sales_order_line | incremental | modified_at | order_number,line_number | 20 |
| erp | inventory_txn | incremental | txn_at | txn_id | 20 |
| files | budget | full | year_month,category,region | 30 |
Reasonable additions as needs appear: a source query override for awkward sources, a partition column for large extracts, an owner, and a notes column. Resist adding transformation SQL.
Incremental loads with a watermark
The watermark pattern has one rule that is easy to get wrong: capture the new high watermark before extracting, and bound the extract by it. Otherwise rows committed during the extract can be skipped forever.
- Read
last_watermarkfrom config. - Query the source for the current maximum of the watermark column: that is
new_watermark. - Extract rows in the half-open window and land them in bronze with the run's
_batch_id. - Merge into silver on
merge_keys. - Only after everything succeeds, write
new_watermarkback to config.
-- Step 2: high watermark
SELECT MAX(modified_at) AS new_watermark FROM erp.sales_order_line;
-- Step 3: bounded extract
SELECT *
FROM erp.sales_order_line
WHERE modified_at > @last_watermark
AND modified_at <= @new_watermark;
-- Step 5: advance, only on success
UPDATE meta.load_config
SET last_watermark = @new_watermark
WHERE config_id = @config_id;
Timestamp watermarks miss two things. Rows from long-running source transactions can commit with a modified_at earlier than a watermark you already advanced past; a small lookback overlap plus an idempotent merge handles it. And hard deletes never show up at all; you need source CDC, soft-delete flags, or a periodic full key reconciliation.
ForEach over config in Fabric Data Pipelines
The pipeline shape is: a Lookup activity reads the active config rows, a ForEach iterates them, and inside the loop a Copy activity (or a notebook) does the work, followed by logging and the watermark update.
Lookup "Get config" query: SELECT * FROM meta.load_config
WHERE is_active = 1 AND load_order = @{pipeline().parameters.wave}
ForEach "Each table" items: @activity('Get config').output.value
Lookup "High watermark"
Copy "Land bronze" source query (dynamic content):
SELECT * FROM @{item().source_system}.@{item().source_object}
WHERE @{item().watermark_column} > '@{item().last_watermark}'
AND @{item().watermark_column} <= '@{activity('High watermark').output.firstRow.new_watermark}'
Script "Log and advance watermark"
A few limits shape the design. The Lookup activity returns a bounded result (historically 5,000 rows and 4 MB), which is plenty for config but not for data. ForEach runs in parallel by default with a configurable batch count (up to 50) and does not respect load_order, so drive waves from an outer sequential loop that invokes a child pipeline per wave. ForEach cannot be nested directly; use an Invoke pipeline activity instead. Use a Switch activity on load_type rather than branching inside expressions. For lakehouse-to-lakehouse work, a single notebook that reads the config and loops in Python, possibly with a thread pool, often beats a ForEach that starts a Spark session per table. Pipelines stay the right tool for Copy from on-premises sources through a gateway.
Logging, idempotence and reruns
Every run writes one row per table to a log, keyed by the pipeline run ID, which is also the _batch_id stamped on every bronze row.
CREATE TABLE meta.load_log (
run_id varchar(64) NOT NULL, -- @pipeline().RunId, also bronze _batch_id
config_id int NOT NULL,
started_at datetime2(6) NOT NULL,
ended_at datetime2(6) NULL,
status varchar(12) NOT NULL, -- 'running', 'succeeded', 'failed'
rows_read bigint NULL,
rows_written bigint NULL,
watermark_from datetime2(6) NULL,
watermark_to datetime2(6) NULL,
error_message varchar(4000) NULL
);
Idempotence means running the same batch twice produces the same result as running it once. Three habits get you there: bronze loads delete any rows already landed for this _batch_id before inserting (or merge on it); silver loads merge on business keys instead of appending; and the watermark advances only after the whole chain for that table succeeds. With those in place, a failed night is fixed by rerunning, not by surgery.
Every load must be safe to run twice. If a rerun needs a manual cleanup step first, the load is not finished.
Schema drift
Sources add, drop and retype columns. Decide per layer how much drift you absorb:
- Bronze absorbs additions. Land new columns automatically with Delta schema evolution, for example
df.write.format("delta").mode("append").option("mergeSchema", "true").saveAsTable("bronze.erp_customer"). - Silver uses explicit column lists. A new source column does not flow downstream until someone adds it on purpose. Removed columns fail loudly.
- Type changes stop the load. Silently casting a changed type is how amounts lose decimals.
- Detect drift deliberately. Compare each source's current schema with a registered column list (
meta.column_registry) on every run, and alert on differences instead of discovering them in a report.
When metadata-driven gets too clever
The pattern decays in predictable ways. Watch for:
- Transformation SQL stored as strings in config rows.
- A growing set of special-case columns (
skip_dedupe,use_alt_key,is_special_7). - Pipeline expressions nobody can read without pasting them into an editor.
- A config table edited by hand in production and absent from source control.
- Debugging that starts with reconstructing the dynamic SQL a run actually executed.
The fix is a boundary: metadata for movement, code for meaning. Bronze landing and standard silver merges are driven by config. Gold dimensions and facts are hand-written, reviewed SQL or notebooks, because each encodes modeling decisions (grain, SCD behavior, unknown members) that deserve a code review, not a row. Keep the config itself in Git, seeded by a deployment script, so a change to what loads is as visible as a change to how it loads.
Declarative transformation tools such as dbt generate the same lineage and dependency graph that control tables approximate. Is a config table still the right abstraction for silver once a declarative tool is available, or only for bronze landing?
The Lineage flow shows the eight sample sources landing in bronze and flowing on to silver, which is exactly the part of the graph a control table drives.