Data quality frameworks

From findscripter/everything-skills · View interactive version

Data quality frameworks is an AI agent skill from the GitHub repository findscripter/everything-skills. 当为数据管道建立质量校验、用 Great Expectations / dbt 测试 / 数据契约约束数据时使用;做按六维度(完整/唯一/有效/准确/一致/时效)定义期望与契约并接入 CI/CD 的可执行方案;不适用于数据源未定义、无权改校验规则或与数据质量无关的任务;触发词:数据质量、data quality、Great Expectations、期望套件、dbt 测试、dbt test、数据契约、data contract、Soda、数据校验、新鲜度。

How to use this skill

Skill file

何时使用

适用:

不该用(负边界):

步骤 / 指令

  1. 锁定关键数据集与质量维度:按六维度选检查项——完整性 expect_column_values_to_not_be_null、唯一性 expect_column_values_to_be_unique、有效性 expect_column_values_to_be_in_set、准确性(交叉引用)、一致性 expect_column_pair_values_A_to_be_greater_than_B、时效性 expect_column_max_to_be_between。
  2. 定义期望/测试与契约规则:遵循「数据测试金字塔」——底层 Schema 测试(结构)、中层单列单元测试、顶层跨表集成测试。
  3. 接入 CI/CD 并定时调度:用 Checkpoint 或 dbt run/test 在流水线中跑校验,失败即阻断。
  4. 设置告警、归属与修复:配置 Slack 等通知、明确 owner 与 remediation 步骤。
  5. 需要更细模板时参考源仓库的 resources/implementation-playbook.md。

原则:尽早测、增量加测、为每条期望写清描述、对失败告警、为契约做版本管理;不要全量测(聚焦关键列)、不要忽略告警、不要漏掉新鲜度、不要硬编码阈值、不要孤立测试(要测关系)。

示例

Great Expectations 初始化与最小套件:

pip install great_expectations
great_expectations init
great_expectations datasource new
import great_expectations as gx
context = gx.get_context()
suite = context.add_expectation_suite("orders_suite")
suite.add_expectation(gx.expectations.ExpectColumnValuesToNotBeNull(column="order_id"))
suite.add_expectation(gx.expectations.ExpectColumnValuesToBeUnique(column="order_id"))
results = context.run_checkpoint(checkpoint_name="orders_checkpoint")
if not results.success:
    raise ValueError("数据质量校验失败")

dbt 测试(schema.yml 片段):

models:
  - name: fct_orders
    columns:
      - name: order_id
        tests: [unique, not_null]
      - name: customer_id
        tests:
          - not_null
          - relationships:
              to: ref('dim_customers')
              field: customer_id
      - name: order_status
        tests:
          - accepted_values:
              values: ['pending','processing','shipped','delivered','cancelled']

数据契约(含 SodaCL 质量校验 + SLA):

apiVersion: datacontract.com/v1.0.0
kind: DataContract
metadata: { name: orders, version: 1.0.0, owner: data-platform-team }
quality:
  type: SodaCL
  specification:
    checks for orders:
      - row_count > 0
      - missing_count(order_id) = 0
      - duplicate_count(order_id) = 0
      - freshness(created_at) < 24h
sla: { availability: 99.9%, freshness: 1 hour, latency: 5 minutes }

注意事项

互见


本条采编自 sickn33/antigravity-awesome-skills(MIT)。

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.