data-pipeline
Design a data pipeline — ETL vs ELT, batch vs streaming, orchestration/DAG, idempotent backfills, schema handling, data-quality checks, and lineage.
- License 许可
- MIT
- 最近更新
- 2026-10-29
- Stars
- ★ 0
- Forks
- 0
01 前言 Front Matter
- name
- data-pipeline
- description
- Design a data pipeline — ETL vs ELT, batch vs streaming, orchestration/DAG, idempotent backfills, schema handling, data-quality checks, and lineage.
02 资源文件 1
- 参考文档routing.yaml405 B
03 SKILL.md 正文
data-pipeline
A pipeline that can't be safely re-run is a pipeline that will eventually corrupt your warehouse. Design idempotency and backfill before you design transforms.
Mode: analytical — judgment inside a fixed frame. Keep the output shape; every verdict cites its evidence; unknowns are marked [TBD] or [VERIFY], never filled in.
When to use
- Building or reworking ingestion/transformation from sources into a warehouse/lake.
- A pipeline is non-idempotent, hard to backfill, or silently dropping/duplicating rows.
- A workflow invokes
polymath-streaming:data-pipeline.
Not this when: you are choosing the target table shape — that is polymath-streaming:data-modeling. For the streaming transport itself, polymath-streaming:streaming-design. For analytic query tuning, polymath-data:sql-optimize.
Inputs
- Sources (DBs, events, files, APIs), volumes, freshness SLA, and destination.
- Whether late/out-of-order or corrected data arrives.
Procedure
- ETL vs ELT: prefer ELT (load raw, transform in-warehouse) when the destination is a modern warehouse/lake — it preserves raw data and makes transforms re-runnable; use ETL when you must transform/filter before landing (PII, cost). State the choice.
- Batch vs streaming by the freshness SLA: batch (scheduled, simpler, cheaper) unless sub-minute freshness genuinely matters; micro-batch as the middle ground. Don't pay for streaming you don't need.
- Orchestration: model as a DAG with explicit dependencies (Airflow/Dagster/etc.); each task is retryable and observable. Avoid hidden cron chains.
- Idempotency + backfill — the core: design every step so re-running a window produces the same result (idempotent writes: upsert/merge on a key, or delete-insert per partition). A backfill for any date range must be a first-class, safe operation.
- Schema handling: validate on ingest; decide schema-on-read vs schema-on-write; version schemas and handle drift (new/removed/renamed columns) without breaking downstream.
- Data quality: assertions at boundaries (row counts, null/range/uniqueness, referential checks); fail or quarantine on violation rather than propagating bad data.
- Late/out-of-order data: define the lateness window and the correction strategy (reprocess affected partitions).
- Lineage + observability: track source→table lineage, freshness, and volume; alert on staleness and anomalies.
Output
Data pipeline: orders → warehouse (Dagster, BigQuery)
Decisions: ELT (raw lands first; PII columns hashed at load) · daily batch — freshness SLA is 6 h, streaming not needed
DAG
extract_orders CDC snapshot per day partition retry 3× · idempotent: overwrite partition
load_raw → raw.orders (partition = order_date) idempotent: delete-insert per partition
transform_orders raw → staging → marts.fct_orders idempotent: MERGE on order_id
quality_gate row count ±20% vs 7-day mean · order_id unique · amount ≥ 0 · FK to dim_customer
on failure: quarantine the partition, stop downstream, page data on-call
Backfill: `dagster job backfill --partitions 2026-01-01...2026-03-31` — same code path, partition by partition
Schema drift: new source columns land in raw automatically; marts only change via a reviewed model PR; removed columns alert
Late data: corrections up to 3 days old → reprocess those 3 partitions nightly
Lineage + freshness: dbt/Dagster lineage graph; alert when fct_orders is older than 6 h
Quality bar
- Every step is idempotent; re-running a window is safe and produces identical output.
- Backfill of an arbitrary range is a defined, first-class operation.
- Data-quality assertions gate the boundaries; violations quarantine, not propagate.
- Batch-vs-streaming is justified by the freshness SLA, not fashion.
04 同仓库更多 Skills
runbook
Write or refresh an operational runbook for an alert/symptom; structured as TL;DR + Pre-checks + Steps + Verification + Rollback + Escalation.
rfc
Draft a lightweight design RFC to docs/rfcs/<slug>.md; Summary, Motivation, Detailed design, Drawbacks, Alternatives, Unresolved questions. A proposal to debate, not a recorded decision (adr).
editorial-pass
Review and tighten prose in a Markdown artifact for a target tone (terse, formal, friendly) without dropping information; preserve quotations and load-bearing constraints.
architecture-review-facilitation
Run an architecture review as a process — entry criteria, reviewer checklist, decision log, and follow-up actions — pairing the design artifact with a red-team pass.
architecture-doc
Write a C4-style architecture document; System Context + Containers (+ Components when interesting) with mermaid diagrams. Describes structure, not a decision (adr) or proposal (rfc).
adr
Write an Architecture Decision Record (Michael Nygard format) to docs/adrs/NNNN-<slug>.md; frontmatter validated by the ADR artifact schema. Records a made decision, not a proposal to debate (rfc).