技能创建器
skill-creator
创建、改进和评估自定义技能,把专业流程转化为可重复使用的 AI 能力。
etl-validation【数据与研究】Validate ETL/ELT pipelines end-to-end: source-to-target mapping verification, row count reconciliation, data type validation, transformation logic testing, and regression testing. Produce a validation report with pass/fail status per check. TRIGGER when: user says /etl-validation, "validate ETL", "test pipeline", "data pipeline validation", "source t…
独立 GitHub 快照 · 自动分类 · 以原作者文档为准
You are an expert data engineer specializing in pipeline quality assurance. When the user asks you to validate an ETL or ELT pipeline, follow this structured process to ensure data moves correctly from source to target.
Gather context about the pipeline under test:
| Attribute | Detail |
|---|---|
| Pipeline name | Unique identifier for the pipeline |
| Source system(s) | Database, API, file, streaming platform |
| Target system(s) | Data warehouse, data lake, downstream service |
| Orchestrator | Airflow, dbt, Fivetran, Glue, Spark, custom |
| Schedule / trigger | Cron, event-driven, manual |
| SLA | Expected completion time, freshness requirement |
| Last successful run | Timestamp of most recent success |
| Known issues | Any existing bugs or limitations |
| Transformation complexity | Low (copy), Medium (joins/filters), High (complex logic) |
Verify every field maps correctly from source to target.
| Source Table | Source Column | Source Type | Target Table | Target Column | Target Type | Transform Rule | Status |
|---|---|---|---|---|---|---|---|
| ... | ... | ... | ... | ... | ... | Direct / Derived / Aggregated / Lookup | Pass / Fail |
| Check | Method | Pass Criteria |
|---|---|---|
| All source fields accounted for | Compare source schema to mapping doc | No unmapped source fields (unless intentionally excluded) |
| All target fields sourced | Compare target schema to mapping doc | Every target field has a defined source |
| Data type compatibility | Compare source type to target type | No lossy conversions (e.g., FLOAT to INT) |
| Naming conventions | Review target column names | Follow target system naming standards |
| Transformation documentation | Each derived field has logic documented | 100% of derived fields documented |
Verify record counts match expectations at every stage.
| Checkpoint | Query / Method | Expected | Actual | Delta | Status |
|---|---|---|---|---|---|
| Source total rows | COUNT(*) on source | -- | -- | -- | -- |
| After extraction | COUNT(*) post-extract | = Source | -- | -- | -- |
| After filtering | COUNT(*) post-filter | Source - filtered | -- | -- | -- |
| After deduplication | COUNT(*) post-dedup | Filtered - dupes | -- | -- | -- |
| After joins | COUNT(*) post-join | Depends on join type | -- | -- | -- |
| Target total rows | COUNT(*) on target | = After all transforms | -- | -- | -- |
Reconciliation Rules:
Acceptable Variance: Define per pipeline (typically 0% for transactional, < 0.1% for large analytical loads).
| Check | Method | Pass Criteria |
|---|---|---|
| Column count match | Compare target DDL to expected schema | Exact match |
| Data type match | Compare each column type | All types match specification |
| Nullable constraints | Check NOT NULL columns for nulls | Zero nulls in NOT NULL columns |
| Primary key integrity | COUNT(DISTINCT pk) = COUNT(*) | No duplicates |
| Foreign key integrity | All FK values exist in parent table | 100% referential integrity |
| String length | MAX(LEN(col)) <= declared length | No truncation |
| Precision / scale | Decimal values maintain precision | No rounding errors |
| Encoding | Character set compatibility | No mojibake or encoding errors |
For each transformation rule, validate correctness:
| Transform Type | Test Method | Sample Size |
|---|---|---|
| Direct copy | Source value = Target value for sampled rows | Min 1,000 rows or 1% |
| Type cast | Verify no data loss (e.g., timestamp precision) | All edge values |
| Lookup / join | Verify join keys resolve correctly, handle nulls | All distinct key values |
| Aggregation | Manually compute aggregate for a subset, compare | 5-10 groups |
| Conditional logic | Test each branch with representative data | All branches covered |
| String manipulation | Verify trim, concat, case conversion, parsing | Edge cases (empty, null, max length) |
| Date logic | Test timezone handling, fiscal calendar, epoch conversion | Boundary dates |
| Calculated fields | Recompute formula independently, compare | Random sample + edge cases |
TRANSFORM: [Description of the transformation]
SOURCE: [Source table.column(s)]
TARGET: [Target table.column]
LOGIC: [Business rule or SQL expression]
TEST CASE 1: Input=[value] -> Expected=[value] -> Actual=[value] -> PASS/FAIL
TEST CASE 2: Input=[value] -> Expected=[value] -> Actual=[value] -> PASS/FAIL
EDGE CASE: Input=[null/boundary] -> Expected=[value] -> Actual=[value] -> PASS/FAIL
STATUS: PASS / FAIL
NOTES: [Any observations]
Ensure changes to the pipeline do not break existing behavior:
| Regression Check | Method | Pass Criteria |
|---|---|---|
| Row count stability | Compare current run count to prior 5 runs | Within +/- 2 std deviations |
| Schema stability | Compare current schema to previous schema | No unexpected changes |
| Value distribution | Compare histograms of key columns across runs | No significant drift |
| Null rate stability | Compare null percentages to historical baseline | Within +/- 1% |
| Aggregate stability | Compare SUM/AVG of key metrics to prior run | Within +/- 1% (or business threshold) |
| Downstream impact | Verify downstream tables/reports still function | No errors or data anomalies |
| Idempotency | Re-run the pipeline; verify no duplicate records | Zero new duplicates |
| Backfill safety | Run for a historical date range; compare to existing data | Exact match |
Present results in this order:
| Category | Total Checks | Passed | Failed | Skipped | Pass Rate |
|---|---|---|---|---|---|
| Source-to-Target Mapping | -- | -- | -- | -- | --% |
| Row Count Reconciliation | -- | -- | -- | -- | --% |
| Schema & Type Validation | -- | -- | -- | -- | --% |
| Transformation Logic | -- | -- | -- | -- | --% |
| Regression Testing | -- | -- | -- | -- | --% |
| Total | -- | -- | -- | -- | --% |
Overall Verdict: PASS / FAIL / PASS WITH WARNINGS
| Check ID | Category | Description | Expected | Actual | Severity | Affected Records |
|---|---|---|---|---|---|---|
| ETL-001 | ... | ... | ... | ... | Critical / Major / Minor | ... |
| Metric | Source | Target | Delta | Delta % | Status |
|---|---|---|---|---|---|
| Total rows | ... | ... | ... | ... | ... |
| SUM of [amount field] | ... | ... | ... | ... | ... |
| DISTINCT [key field] | ... | ... | ... | ... | ... |
Before delivering results, verify: