IntermediatePipeline Architecture · 32 min · 12 challenges

Pipeline Operations: Intermediate

Say a pull request at Netflix changes watch_time in a playback table from seconds to minutes on a Monday. A forward lineage walk names the 140 downstream tables and dashboards and their owners, and a data diff in CI shows every row's watch_time divided by 60 before merge. Those steps keep Tuesday's Top 10 built on real viewing numbers, and this lesson works them on a small orders pipeline.

What Telemetry Is Worth Keeping

Daily Life
Interviews
Every log line is paid for in 3 places, and so is every metric series and trace span. Ingest and storage are the first 2; the third is each query that reads it. It is paid for again in attention, because a dashboard of 60 panels hides the 3 that matter during an incident. Telemetry is worth keeping when it answers a question that someone acts on, and the table below applies that test to each signal.

Start from the question, then pick the signal

QuestionSignal that answers itWho acts on it
Is the output late or wrong right now?Freshness and row-count checks on the final tablesOn-call engineer, from an alert
Which task in which run failed, and why?Task logs that carry `run_id`, plus task statusOn-call engineer, while debugging
Is this pipeline getting slower or more expensive?Daily rollups of duration and cost per taskOwning team, at a monthly review
What did row 8,812,004 look like inside step 3?No telemetry; query the table or the dead letter queueAlmost nobody, almost never

The last row is where budgets leak. A task that logs every row of a 200-million-row load writes 200 million lines per run; at 300 bytes a line, that is 60GB of logs a day from 1 task, and the line for row 8,812,004 will never be read. Log once per batch instead: the run_id and the duration, and how many rows came in and went out, with rejected rows counted separately. Those few lines per run answer the second question in the table.

Cardinality decides the metric bill

A metrics store keeps 1 time series per unique combination of label values. Storage cost grows with the series count, and so does query cost. With pipeline and task as its labels, the metric rows_written makes 480 series over 40 pipelines of 12 tasks each. That is cheap, and it is enough to see which pipeline and task slowed down or shrank. Add a customer_id label, which has 50,000 distinct values, and each of those series splits 50,000 ways.

24M
rows_written series with customer_id

A label belongs on a metric when its set of values grows with the platform, such as pipeline and task, or env and status. Values that grow with the data go into log lines, where they leave no permanent series behind; customer_id and order_id are examples, as are run_id and partition_date. run_id looks harmless, but as a label it mints a new series every run, each holding the points of a single run.

Keep detail briefly, keep summaries for 13 months

Questions about raw detail come within days of an incident. Questions about trends, such as whether orders_daily has slowed since spring, come months later. Retention is therefore tiered: full detail for a short window, then downsampled rollups for a long one.

SignalFull detail keptAfter thatWhy this window
Task logs14 daysError lines kept 90 days, the rest deletedIncidents are debugged within a week; repeat errors show up over a quarter
Task metrics at 10-second points15 days5-minute rollups kept 13 months13 months lets you compare a month with the same month last year
Run tracesEvery failed run and 5% of successful runs, for 7 daysDeletedFailures need the full path; latency trends need only a sample
Query cost records13 monthsDeletedSmall rows that feed the monthly cost review
TIP
Before adding a signal, name the thing that will read it. That can be an alert or a dashboard panel, or a step in a runbook. A signal nothing reads is cost with no return, and it buries the signals that matter.
Multiple Choice

A teammate proposes adding order_id as a label on the rows_rejected metric so on-call can see which orders failed validation. The pipeline rejects roughly 2,000 of its 400,000 daily orders, each with a new order_id. What should the review say?

Lineage and Blast Radius

Daily Life
Interviews
Lineage is the graph of which datasets are built from which. The nodes are tables and models, plus the dashboards that read them, and each edge records that 1 node reads another. The same graph answers 2 different questions depending on the direction you walk it.
✓Backward lineage (upstream)
  • From a node to everything it reads, then everything those read
  • Answers: where could this bad number have come from?
  • Used during an incident to find the origin
✗Forward lineage (downstream)
  • From a node to everything that reads it, and onward
  • Answers: what breaks if this node changes or goes bad?
  • Used before a change and during an incident to size the damage

The orders_daily graph

Raw
Staging
Curated
Serving
Consumers
raw table
raw.payments
raw table
raw.orders
staging table
stg payments
staging table
stg orders
fact table
fct orders
aggregate table
agg daily revenue
aggregate table
customer ltv
Finance
Revenue dashboard
Support operations
Refunds dashboard
Data science
Churn model

Arrows point from the dataset that is read to the dataset or consumer built from it.

Blast radius is the set of nodes forward of a change or a failure, together with the people who own them. Walking forward from stg_payments reaches 6 nodes. Half of them are the revenue and refunds dashboards and the churn model; the rest are the internal tables fct_orders and agg_daily_revenue, plus customer_ltv. The count alone misleads, so weight each node by who depends on it: the revenue dashboard that Finance closes the month with outranks 3 internal tables.

Column-level lineage narrows the radius

Table-level lineage says fct_orders reads stg_payments. Column-level lineage says which columns feed which: fct_orders.net_revenue is computed from stg_payments.fee_usd, and of the nodes after fct_orders only agg_daily_revenue reads net_revenue. A change to how fee_usd is rounded therefore alters values in fct_orders and agg_daily_revenue and on the revenue dashboard, 3 nodes in all, and the refunds and churn owners need no warning. Renaming or dropping fee_usd is different, because the build of fct_orders fails, everything after it goes stale, and the radius is back to all 6.

Where lineage comes from

Capture methodHow it worksWhat it misses
Parse pipeline codeRead each task's SQL and record the tables in its `FROM` and `JOIN` clausesDashboards, notebooks and ad hoc queries that read tables directly
Parse query logsRead every query the warehouse ran over a window, from any clientReaders that did not run during the window
Declared task inputs and outputsEach orchestrator task lists what it reads and writesAnything someone forgot to declare

Code parsing alone never sees the analyst whose notebook reads fct_orders every Monday, and that analyst is the person who gets surprised. Merging code lineage with 30 days of query logs covers most real readers; declared inputs fill the gaps where SQL is assembled at runtime and cannot be parsed.

Root cause: walk back until the inputs are healthy

On the morning of 2026-10-21, Finance reports the revenue dashboard showing 2026-10-20 revenue 38% below its 7-day average. Backward lineage from the dashboard lists the nodes to check; a row count on each for that date shows its health.
NodeRows for 2026-10-207-day averageStatus
fct_orders255,000410,000Low
stg_payments254,600408,900Low
stg_orders411,200409,800Normal
raw.payments409,700408,300Normal
raw.orders411,500410,100Normal

The origin is the most upstream node that is unhealthy while every node it reads is healthy. fct_orders is low, but stg_payments, one of its inputs, is also low, so the fault entered earlier. stg_payments is low while its only input, raw.payments, is normal: the rows disappeared inside stg_payments. Its last deploy on 2026-10-19 added WHERE currency = 'USD'. A payment processor onboarded that week sends 'usd' in lowercase. The fix lands in stg_payments, and the backfill rebuilds it and every node forward of it, in lineage order.

Multiple Choice

A Monday alert says customer_ltv has 0 rows for 2026-10-25. Every node upstream of it, from fct_orders back to both raw tables, has normal row counts for that date. Which reading of the lineage is correct?

Cost Attribution

Daily Life
Interviews

A warehouse bill reports daily spend for each account and compute cluster. It cannot say that orders_daily cost $4,200 last month, because the warehouse has no idea what a pipeline is. Cost attribution supplies that idea: every query a pipeline sends carries a tag naming who sent it, and the warehouse's query log turns into a ledger you can group by pipeline and then break down by task or by run.

What goes in a query tag

{
"pipeline": "orders_daily",
"task": "build_fct_orders",
"run_id": "orders_daily__2026-10-20T06:00",
"owner": "payments-data",
"env": "prod"
}

Each field has a job. pipeline and task are the grouping keys for the rollup. run_id ties a query's cost to 1 run and to that run's logs; it is safe here because the query log stores 1 row per query and mints no metric series. owner says whom to talk to. env keeps CI and development spend out of the production numbers.

Many warehouses let a client attach a tag or label to its session and record it on each query in the log. Set the tag in 1 place, the orchestrator's task wrapper or the shared database client, so every task inherits it. A hand-typed tag is missing from the first query someone writes in a hurry, which lands in the untagged bucket.

The rollup

SELECT
COALESCE(
JSON_EXTRACT_SCALAR(query_tag, '$.pipeline'),
'untagged'
) AS pipeline,
COUNT(DISTINCT JSON_EXTRACT_SCALAR(query_tag, '$.run_id')) AS runs,
SUM(cost_usd) AS total_cost_usd
FROM query_history
WHERE start_time >= CURRENT_TIMESTAMP - INTERVAL '30' DAY
AND COALESCE(JSON_EXTRACT_SCALAR(query_tag, '$.env'), 'prod') = 'prod'
GROUP BY 1
ORDER BY total_cost_usd DESC
Joined with lineage, the rollup gains its most useful column: how many distinct users and dashboards queried the pipeline's output tables in the same 30 days, from the query-log lineage of the previous section.
pipeline30-day costrunscost per runprior 30 days, cost per runreaders in 30 days
clickstream_sessions$11,800720$16.39$16.103
marketing_attribution$6,90030$230$2280
orders_daily$4,20030$140$609
untagged$3,0000n/an/an/a
inventory_snapshot$2,10030$70$695
$28,000
total 30-day warehouse spend
10.7%
of 30-day spend carries no tag

Reading it for savings

Patterns worth a closer look
  • No readersmarketing_attributionIt spends $6,900 a month on tables nobody queried in 30 days. Ask the owner what still depends on them before pausing the schedule.
  • Cost per run jumpedorders_dailySame cadence, cost per run up from $60 to $140. Something in the code changed, often a deploy that swapped an incremental load for a full rebuild.
  • Cadence above needclickstream_sessionsIt makes 720 hourly runs for 3 readers. If each run reprocesses the whole day so far and readers look once each morning, a daily run removes most of the repeated work.
  • Untagged spendthe untagged rowFind who sends untagged queries first. The $3,000 here exceeds inventory_snapshot's whole month, enough to hide a pipeline that size; a working threshold, such as 5% of spend, says when to chase it.

Rank these by expected saving, then by the risk of acting. Pausing an unread pipeline saves the most here and comes undone in a minute. The orders_daily jump is smaller in dollars, but it is a defect that keeps billing until someone finds it, and the run_id in every tag leads to the first expensive run. The steady pipelines can wait.

TIP
Report cost per run alongside monthly cost. A pipeline whose monthly cost doubles because it now runs twice as often reflects a cadence decision; one whose cost per run doubles hides a code change to find.
Multiple Choice

The team has 1 afternoon for orders_daily, whose cost per run rose from $60 to $140 starting with the first run after a deploy on 2026-09-24. Which next step uses the attribution data most directly?

CI/CD for Pipelines

Daily Life
Interviews
A pipeline change can pass every compile check and still double the rows or drop a filter. It can also change what a column means. CI for pipelines therefore tests the data a change produces as well as the code. The constraint is time: a CI run that takes most of an hour gets skipped, batched into pull requests too large to review, or merged around.

4 layers, cheapest first

LayerWhat runsWhat it catchesRough time
1. StaticParse every SQL file, load every DAG, lint, check for cycles and missing referencesSyntax errors, broken imports, a task reading a table that no longer existsUnder 1 minute
2. UnitTransform logic on hand-written fixture rows with expected outputsWrong dedupe or join logic, mishandled nulls and edge cases1 to 2 minutes
3. IntegrationBuild changed tables in a CI schema from 1 recent day of prod inputs, then run the quality checks prod runsRow explosions, failed uniqueness, nulls in required columns3 to 10 minutes
4. Data diffCompare the CI output with prod output for the same daySilent changes: rows gained or lost, amounts that moved1 to 5 minutes
Each layer catches failures the one before it cannot see. Static checks know nothing about data. Unit tests prove logic on a few hand-written rows, never on 400,000 real ones. An integration build can pass every check and still shift a revenue total; the data diff turns 'the build passed' into 'here is what changes in prod'.
//

Layer 2: a unit test on fixture rows

def dedupe_latest(rows):
latest = {}
for row in rows:
key = row["order_id"]
if key not in latest or row["updated_at"] > latest[key]["updated_at"]:
latest[key] = row
return sorted(latest.values(), key=lambda r: r["order_id"])
def test_dedupe_keeps_latest_version():
rows = [
{"order_id": 7, "status": "placed", "updated_at": 1},
{"order_id": 7, "status": "shipped", "updated_at": 2},
{"order_id": 9, "status": "placed", "updated_at": 1},
]
result = dedupe_latest(rows)
assert [r["status"] for r in result] == ["shipped", "placed"]

The fixture holds 3 rows built around the case that matters: 2 versions of order 7. A useful next fixture is 2 versions with the same updated_at, which the function resolves by keeping whichever arrived first. The test needs no warehouse and runs in milliseconds, so it runs on every push.

//

Layer 4: a data diff against prod

SELECT
COUNT_IF(c.order_id IS NULL) AS missing_in_ci,
COUNT_IF(p.order_id IS NULL) AS new_in_ci,
COUNT_IF(p.amount_usd <> c.amount_usd) AS amount_changed
FROM prod.fct_orders AS p
FULL OUTER JOIN ci_pr_412.fct_orders AS c
ON p.order_id = c.order_id
WHERE COALESCE(p.order_date, c.order_date) = DATE '2026-10-20'

For a pure refactor, every count should be 0. For the lowercase 'usd' fix from the lineage example, diffing 2026-10-20 against the broken prod output should show around 155,000 rows in new_in_ci and nothing missing or changed. That number is the evidence the fix restores the lost payments and touches nothing else.

Slim CI: build only what the change touches

Slim CI uses lineage to choose the build set, which is the tables a pull request modified plus every table downstream of them. Unmodified upstream tables are read from prod instead of rebuilt. In a project of 600 tables, a pull request that edits stg_payments builds 4 tables, stg_payments and fct_orders as well as agg_daily_revenue and customer_ltv; the dashboards and the churn model sit outside the project and stay as they are.

52 min
CI time when building all 600 tables
6 min
slim CI time for the stg_payments change
Where slim CI can miss
  • ▸Reading upstream tables from a stale prod state tests against old data; refresh that state before each CI run.
  • ▸A change to shared code or config, such as a common SQL snippet or a currency list, must mark every table that uses it as modified.
  • ▸A full build on the main branch each night catches whatever slim selection skipped during the day.

CD: ship the artifact you tested

Deployment promotes the exact code that passed CI to prod on merge, with no rebuild in between. A backfill for changed values runs in forward-lineage order, so each table is rebuilt only from inputs already on the new logic. Order alone leaves a window: until agg_daily_revenue is rebuilt, the refunds dashboard shows new values and the revenue dashboard old ones. Building the affected partitions in a separate schema and swapping them in together closes it.

Multiple Choice

A pull request that edits fct_orders is described as 'refactor, no behavior change'. Its data diff reports missing_in_ci = 0, new_in_ci = 0 and amount_changed = 18,400. What should the reviewer conclude?

Instrumenting a Pipeline E2E

Daily Life
Interviews

Take orders_daily as it stood before this lesson: 6 tasks on a daily schedule, failure emails to a shared inbox, no metrics or lineage, and no tags or CI. Instrumenting all of it in 1 project takes a quarter and pays nothing until the end. Sequencing it so each step works on its own gives the team a better pipeline every week, and a point to stop at whenever priorities shift.

7 steps, each useful alone

WeekStepValue on its ownBuilds on
1Freshness and row-count check on `agg_daily_revenue` at 07:00 UTC, paging the ownerThe team hears about a late or short load before Finance's 08:00 UTC reviewNothing
2`run_id` on every log line from every taskA single search returns a failed run's whole storyThe week 1 page links to the run
3Duration and row metrics per task, labelled `pipeline` and `task`Shows which task slowed down or shrank, and since when`run_id` links a metric spike to the run's logs
4Quality gates at the `stg_payments` and `stg_orders` boundariesBad batches stop before they reach `fct_orders`Week 3 metrics: block below 50% of the trailing average, tighten after a few weeks
5Lineage from parsed code and 30 days of query logsEvery page names the downstream nodes and their ownersWeek 1 pages now carry the blast radius
6Query tags on every taskCost per run and per task on the monthly rollupWeek 2 `run_id` joins a costly query to its run's logs
7Slim CI with the 4 test layersBroken changes stop at the pull requestWeek 5 lineage picks the build set; week 4 gates run in layer 3
The order follows the questions an incident raises: is something wrong, where, who is affected, what is it costing, and how do we stop the next one. Detection goes first because every later step assumes the team knows a failure happened. CI comes last here even though it prevents incidents, because slim selection needs lineage and layer 3 needs the gates.
orchestrator
extract payments
RETRY3BACKOFFexponential, 30s base
orchestrator
extract orders
RETRY3BACKOFFexponential, 30s base
orchestrator
stg payments
IDEMPOTENCYoverwrite date partition
orchestrator
stg orders
IDEMPOTENCYoverwrite date partition
orchestrator
staging gate
ERRORblock downstream, page owner
orchestrator
build fct orders
PARTITIONS32BACKFILLrebuild by date in lineage order
orchestrator
build agg daily revenue
SLAready by 07:00 UTCMONITORpage payments-data if late or short
Finance
Revenue dashboard

orders_daily after week 7. Every task sends tagged queries and logs with the run's run_id; the gate holds bad staging batches, and the final task carries Finance's freshness promise.

✓Do
  • Ship each step to prod before starting the next
  • Alert on the output table first and on task failures second
  • Reuse run_id as the key that joins logs to tags, and to pages too
  • Set gate thresholds from the metric history you already collect
✗Don't
  • Start with CI on a pipeline whose failures nobody sees
  • Label metrics with run_id or order_id, or with partition_date
  • Rely on engineers to type query tags by hand in each task
  • Roll out all 7 steps as 1 change at the end of the quarter
When the order should change
  • ▸If the bill is the complaint, start with query tags: pipeline and task work alone, and run_id can join later.
  • ▸When detection already works and deploys cause most incidents, CI moves earlier: start with layers 1 and 2.
  • ▸If lineage shows the pipeline has no readers, ask whether it should run at all before instrumenting it.
Multiple Choice

Another team asks for help instrumenting clickstream_sessions, the $11,800-a-month hourly pipeline with 3 readers. Failures are rare; the bill is the complaint. Which first 2 steps fit?

Practice across all 5 sections

Multiple Choice

In week 9 the 07:00 UTC check pages: agg_daily_revenue has no partition for 2026-10-23. The page links run orders_daily__2026-10-23T06:00. The staging gate passed, and logs show build_fct_orders still running at 50 minutes, against the 12 its duration metric shows on a normal day. Its tagged queries have already cost 3 times a normal run, and the only change since the last good run is a merge on 2026-10-22. Which response uses the instrumentation best?

❯❯❯PUTTING IT ALL TOGETHER

> On a Monday at a ride-hailing company, the driver payouts dashboard shows weekend earnings 12% below normal, and the same week Finance asks why warehouse spend rose by a fifth. The payouts pipeline already has a freshness page, run_id on every log line, task metrics labelled by pipeline and task, lineage from code and query logs, query tags and slim CI.

Backward lineage from the dashboard, with a row count per node, finds the first short table whose inputs are normal, and that is where the payout rows were lost.
The run_id of that table's run leads to its logs and, through the query tags, to what the same run cost.
The cost rollup grouped by task shows whether the spend rise and the short table trace back to the same deploy.
Forward lineage from the origin lists every payout report and owner to warn, and sets the order of the backfill.
The fix goes through slim CI, where the data diff should show the missing weekend rows returning and no other values moving.
Tiered retention keeps the weekend's full logs for 14 days, long enough for this investigation, and 13 months of rollups to show when the spend began to climb.
KEY TAKEAWAYS
Keep a signal only when a named alert or panel reads it, or a step in a runbook does; keep detail for days and rollups for 13 months.
Metric labels take values that grow with the platform; values that grow with the data, run_id included, belong in logs.
The origin of an incident is the most upstream unhealthy node whose inputs are healthy; forward lineage from a change or failure is its blast radius.
Tag every query from the orchestrator, then read the cost rollup for unread outputs, cost-per-run jumps and cadence above need.
Test pipeline changes in 4 layers, and let lineage limit CI to changed tables and their descendants so it runs on every push.
Instrument an existing pipeline detection first and prevention last, shipping each step before starting the next.

Keep telemetry that earns its cost, trace incidents through lineage, price each pipeline, and test before you ship.

Category
Pipeline Architecture
Difficulty
intermediate
Duration
32 minutes
Challenges
12 hands-on challenges

Topics covered: What Telemetry Is Worth Keeping, Lineage and Blast Radius, Cost Attribution, CI/CD for Pipelines, Instrumenting a Pipeline E2E

Lesson Sections

  1. What Telemetry Is Worth Keeping (concepts: Pipeline Monitoring)

    Every log line is paid for in 3 places, and so is every metric series and trace span. Ingest and storage are the first 2; the third is each query that reads it. It is paid for again in attention, because a dashboard of 60 panels hides the 3 that matter during an incident. Telemetry is worth keeping when it answers a question that someone acts on, and the table below applies that test to each signal. Start from the question, then pick the signal Cardinality decides the metric bill Keep detail bri

  2. Lineage and Blast Radius (concepts: Dependency Management)

    Lineage is the graph of which datasets are built from which. The nodes are tables and models, plus the dashboards that read them, and each edge records that 1 node reads another. The same graph answers 2 different questions depending on the direction you walk it. The orders_daily graph Column-level lineage narrows the radius Where lineage comes from Root cause: walk back until the inputs are healthy On the morning of 2026-10-21, Finance reports the revenue dashboard showing 2026-10-20 revenue 38

  3. Cost Attribution (concepts: Pipeline Monitoring)

    What goes in a query tag Many warehouses let a client attach a tag or label to its session and record it on each query in the log. Set the tag in 1 place, the orchestrator's task wrapper or the shared database client, so every task inherits it. A hand-typed tag is missing from the first query someone writes in a hurry, which lands in the untagged bucket. The rollup Joined with lineage, the rollup gains its most useful column: how many distinct users and dashboards queried the pipeline's output t

  4. CI/CD for Pipelines (concepts: CI/CD for Pipelines)

    A pipeline change can pass every compile check and still double the rows or drop a filter. It can also change what a column means. CI for pipelines therefore tests the data a change produces as well as the code. The constraint is time: a CI run that takes most of an hour gets skipped, batched into pull requests too large to review, or merged around. 4 layers, cheapest first Each layer catches failures the one before it cannot see. Static checks know nothing about data. Unit tests prove logic on

  5. Instrumenting a Pipeline E2E (concepts: Pipeline Monitoring)

    7 steps, each useful alone The order follows the questions an incident raises: is something wrong, where, who is affected, what is it costing, and how do we stop the next one. Detection goes first because every later step assumes the team knows a failure happened. CI comes last here even though it prevents incidents, because slim selection needs lineage and layer 3 needs the gates. Practice across all 5 sections