Community研究與資料分析github.com

設計回填與重播

規劃並執行安全的資料回填與重播作業,包括冪等重新處理歷史時間區間、分割區逐區執行、隔離回填運算與正式環境、驗證結果,以及避免重複計數或歷史資料變更。適用於回填新模型或修正後的模型、修復錯誤後重新處理、重播事件,或在不破壞現有資料的情況下為新管線載入歷史資料。

設計回填與重播 是什麼?

這個技能的核心目標是引導資料工程師安全且有效率地執行資料回填 (backfill) 與重播 (replay) 作業。它強調回填是資料工程中最危險的常規操作,因為它會改寫歷史資料;操作不當可能導致重複計數、變更昨天的數字,或使正式環境超載。因此,此技能要求所有轉換作業必須先擁有冪等性 (idempotency),也就是重複執行與執行一次的結果完全相同,這是安全回填的必要前提。該技能支援資料倉儲、Airflow 與 dbt 等平台,並提供一套結構化的工作流程,從確認冪等性、精確定義時間區間與分割區粒度、單一分割區試運行並驗證、逐區執行(限制並行度)、隔離回填運算資源,到最後的總體驗證與恢復正常排程。此外,它也列出了常見的陷阱,例如對非冪等作業進行回填、一次執行過大的無邊界作業、共用正式環境運算資源、未進行驗證、中途變更處理邏輯,以及忽略相依的下游資料表,這些都可能導致資料不一致或系統問題。

相容平台~Claude Code~Codex CLI~Cursor
npx skills add https://github.com/Unknown-333/awesome-data-engineering-skills/tree/main/skills/designing-backfills-and-replays

Installed? Explore more 研究與資料分析 skills: affaan-m/uspto-database, affaan-m/scholar-evaluation, affaan-m/literature-review · View all 6 →

在你喜歡的 AI 中提問

開啟一個已預先載入此 Agent Skill 的新對話。

說明文件

設計回填與重播 是做什麼的?

使用時機

  • 為新模型 / 管線載入歷史資料。
  • 修復轉換錯誤後重新處理過去的時間區間。
  • 重播事件或從原始資料重新衍生資料表。
  • 不要用於一般增量執行(請改用 building-dbt-models / authoring-airflow-dags)。

為何需要謹慎處理

回填是資料工程中最危險的常規操作:它會改寫歷史紀錄。執行不當會造成重複計數、改變昨天的數字,或使正式環境超載。正確執行時,它則是無趣且可重複的。先決條件是冪等性(請參閱 writing-idempotent-transformations)。

工作流程

- [ ] 回填前確認轉換為冪等(重複執行 == 執行一次)
- [ ] 定義精確的時間區間與分割區粒度
- [ ] 試運行一個分割區;比對計數 / 總和與來源是否一致
- [ ] 逐區執行(限制並行度),而非一次全部執行
- [ ] 隔離回填運算與正式環境的工作負載
- [ ] 驗證總數並核對;然後恢復正常排程
  1. 先證明冪等性。 如果重新執行一個時間區間會改變結果,請先修正此問題再觸碰歷史紀錄。對非冪等作業進行回填會使資料倍增。
  2. 精確界定範圍。 明確的開始 / 結束時間以及分割區單位(天 / 小時 / 地區)。
  3. 試運行一個分割區 並與來源比對,再進行大規模執行。
  4. 分批執行。 以有限批次處理分割區,以便監控、暫停與恢復 — 絕不執行一個巨大的無邊界作業。
  5. 隔離運算資源。 使用獨立的資料倉儲 / 叢集 / 資源池,避免回填影響正式環境的 SLA。
  6. 驗證 + 恢復。 核對回填範圍內的總數,然後交還給正常的排程。

模式

冪等逐分割區回填 — 每個分割區的覆蓋都是獨立的,且可安全重試:

# 限制並行度,一次一天;每一天覆蓋自己的分割區。
for day in $(seq_dates 2026-01-01 2026-01-31); do
  run_transform --run-date "$day"   # 僅對該天執行 delete-insert / MERGE
done

Airflow — catchup / backfill 重新執行時間區間;僅在任務為冪等且以資料區間為參數時才安全。dbt — 將增量模型過濾至目標時間區間,或對有限區間執行 --full-refresh。

隔離 + 流量管制 — 使用專用資料倉儲 / 叢集,並設定並行上限,避免回填影響即時儀表板。

常見陷阱

  • 對非冪等作業進行回填 — 造成重複或總數變動;請先使其具備冪等性。
  • 一次執行巨大的無邊界作業 — 無法監控或恢復,且會使正式環境超載;請逐分割區執行。
  • 共用正式環境運算資源 — 回填會造成負載高峰而破壞 SLA;請隔離。
  • 未進行驗證 — 預設成功卻不核對範圍內的計數 / 總和。
  • 回填中途變更邏輯 — 造成歷史不一致;請鎖定整個執行過程的程式碼版本。
  • 忽略下游相依 — 回填基礎資料表卻未重新整理相依的資料超市 / 彙總,會導致它們不一致。

Individual skills in this repo

This repo contains 9 individual skills — each has its own dedicated page.

Unknown-333/authoring-airflow-dags

Write production-grade Apache Airflow DAGs using the TaskFlow API — idempotent tasks, correct scheduling and catchup, retries/SLAs, connections/variables, and avoiding top-level code. Use when creating or reviewing Airflow DAGs, scheduling pipelines, wiring task dependencies, configuring retries/backfills, or fixing non-idempotent tasks.

Unknown-333/building-dagster-assets

Build Dagster pipelines using software-defined assets — asset dependencies, partitions, resources and IO managers, asset checks, and schedules/sensors. Use when creating Dagster assets or jobs, modeling data as assets, adding partitions or backfills, wiring resources/IO managers, or migrating from task-based orchestration to assets.

Unknown-333/building-dbt-models

Build well-structured dbt models — staging/intermediate/marts layers, ref() and source(), materializations, and incremental models with the right strategy. Use when creating or refactoring dbt models, choosing table vs view vs incremental, structuring a dbt project, or writing incremental logic.

Unknown-333/building-feature-pipelines

Build ML feature pipelines and feature stores — point-in-time-correct joins to avoid label leakage, offline/online parity, feature freshness and backfills, and materialization with tools like Feast. Use when engineering features for ML, preventing train/serve skew or data leakage, building a feature store, or backfilling historical features for training.

Unknown-333/building-iceberg-tables

Design and operate Apache Iceberg tables — partitioning and hidden partitioning, partition/schema evolution, snapshots and time travel, compaction and small-file cleanup, and MERGE/upsert for lakehouse tables on Spark, Flink, Trino, or Snowflake. Use when creating or maintaining Iceberg tables, choosing partitioning, evolving schema/partitions, or fixing small-file and metadata bloat.

Unknown-333/building-ingestion-pipelines

Build batch and incremental data ingestion (extract-load) pipelines — full vs incremental extraction, change data capture (CDC), watermarks and high-water marks, API pagination and rate limits, and choosing managed EL tools (Fivetran, Airbyte) vs custom code. Use when ingesting data from databases, APIs, files, or SaaS into a warehouse/lake, or designing incremental extraction and CDC.

Unknown-333/building-kafka-consumers

Build reliable Apache Kafka consumers and producers — consumer groups and partition assignment, offset commit strategy, at-least-once vs exactly-once, idempotent/transactional producers, rebalancing, and dead-letter handling. Use when writing Kafka consumers/producers, configuring offset commits or consumer groups, tuning throughput, or handling rebalances and poison messages.

Unknown-333/debugging-data-pipelines

Systematically root-cause data pipeline failures and data incidents — job errors, wrong or missing data, duplicates, and freshness misses — by tracing lineage upstream, isolating the failing stage, reconciling against source, and planning a safe fix and backfill. Use when a pipeline fails, numbers look wrong, data is missing or duplicated, a dashboard is stale, or a stakeholder reports a data discrepancy.

Unknown-333/designing-data-contracts

Define and enforce data contracts between producers and consumers — explicit schema, semantics, ownership, SLAs, and versioning — to prevent silent upstream changes from breaking downstream pipelines. Use when a producer schema change could break consumers, defining an interface between teams/services and the warehouse, or adding schema enforcement at ingestion.

相關技能