AIDP テーブルに対するデータ品質ルールチェック(データの正確性と信頼性を確認する各種検査)を実行します。空の項目がないか、重複がないか、値の範囲が妥当か、関連データの整合性が取れているか、データが最新か、といった5種類の検査に対応しています。 **次のような場合に使用:** - ユーザーがデータの妥当性を確認したい - 空の項目、重複レコード、孤立したデータ(関連先が存在しないデータ)をチェックしたい - 特定の列が許された値の範囲内にあることを確認したい - データ処理パイプライン(一連のデータ処理工程)の実行条件として品質検査を組み込みたい 各ルールは Spark SQL(大規模データ処理言語)の限定された形式で表現され、検査結果は合格・不合格とともに問題のあるデータ件数をレポートします。
Run data-quality rule checks on AIDP tables — not-null, uniqueness, allowed ranges/sets, referential integrity, and freshness. Use when the user wants to validate data, check for nulls/duplicates/orphans, assert a column's domain, or gate a pipeline on quality. Expresses each rule as bounded Spark SQL and reports pass/fail with offending counts.
aidp-data-quality — Spark SQL によるルールチェックAIDP テーブルを明示的なデータ品質ルールに基づいて検証します。
各ルールは範囲を限定した Spark SQL にコンパイルされ、同梱のヘルパースクリプトで実行されます。
MCP も ai-data-engineer-agent リポジトリも不要です。
| ルール | チェック内容(違反件数) |
|---|---|
| not-null(非 NULL) | COUNT(*) WHERE col IS NULL |
| unique(一意性) | COUNT(*) - COUNT(DISTINCT key)(または GROUP BY key HAVING COUNT(*)>1) |
| range / set(範囲 / 値集合) | COUNT(*) WHERE col NOT BETWEEN lo AND hi / col NOT IN (...) |
| referential(参照整合性) | COUNT(*) child LEFT JOIN parent ... WHERE parent.key IS NULL |
| freshness(鮮度) | MAX(ts) を SLA と比較(例: datediff(current_date, MAX(ts)) <= N) |
テーブル/カラムを特定し、参照整合性チェックの結合キーは .aidp/catalog.md から取得します(推測は禁止)。
利用可能であれば .aidp/semantic.md の値辞書からルール定義を取り込みます。
クラスターが RUNNING 状態であることを確認(aidp-cluster-ops / oci raw-request)したうえで、
各ルールの違反件数 SQL を同梱ヘルパーで実行します(0 件 → PASS、1 件以上 → FAIL):
python "$PLUGIN_DIR/scripts/aidp_sql.py" --region <region> --datalake <DATALAKE_OCID> --workspace <ws> \
--cluster <cluster-key> \
--code "spark.sql('''SELECT COUNT(*) AS v FROM cat.sch.t WHERE col IS NULL''').show()"
このスクリプトは api_key DEFAULT プロファイルから UPST を発行し、スクラッチノートブックを自動作成して、
status / outputs / spark_job_ids を含む JSON を返します。
AIDP_SESSION は不要(--session-profile はオプション)です。
件数が 0 以外の場合は FAIL とし、違反行のサンプルを別途 LIMIT 付きのクエリで取得します。
ルール・対象・結果・違反件数をまとめたサマリーテーブルを出力します。
以下の対応を提案します:
aidp-pipelines)のゲーティングタスクとして組み込む検証済みルールを .aidp/dq-rules.md に登録することで、後から再実行できます
(.aidp/verified-queries.md のデータ品質版に相当)。
各エントリには、対象テーブル/カラム・ルール種別(上記5種)・違反 SQL(違反件数をカウント → 0 で PASS)・
last-result / last-checked を記録します。
再実行時は各エントリの違反 SQL を scripts/aidp_sql.py 経由で実行し、
結果を PASS (0) または FAIL (<件数>) に更新して、クラスターと実行日を記録します。
status: ok かつ 0 件が確認されない限り、PASS とマークしてはなりません。
フォーマットおよび再実行ルール: references/dq-rules.md
scripts/aidp_sql.py で実際に実行してください。status: ok の結果なしにルールを PASS と断言することは禁止です。status: error を返した場合は、エラー内容を読み、カタログに基づいて SQL を修正してから再試行してください。.aidp/dq-rules.md のルールセット形式と再実行方法)aidp-data-quality — rule checks via Spark SQLValidate AIDP tables against explicit data-quality rules, each compiled to bounded Spark SQL and executed
with the bundled helper — no MCP and no ai-data-engineer-agent repo required.
| Rule | Check (violations) |
|---|---|
| not-null | COUNT(*) WHERE col IS NULL |
| unique | COUNT(*) - COUNT(DISTINCT key) (or GROUP BY key HAVING COUNT(*)>1) |
| range / set | COUNT(*) WHERE col NOT BETWEEN lo AND hi / col NOT IN (...) |
| referential | COUNT(*) child LEFT JOIN parent ... WHERE parent.key IS NULL |
| freshness | MAX(ts) vs SLA (e.g. datediff(current_date, MAX(ts)) <= N) |
.aidp/catalog.md for referential checks (don't guess).
Pull rule definitions from .aidp/semantic.md value dictionaries where available.aidp-cluster-ops / oci raw-request), then for each rule run the
violation-count SQL with the bundled helper (PASS if 0, else FAIL):python "$PLUGIN_DIR/scripts/aidp_sql.py" --region <region> --datalake <DATALAKE_OCID> --workspace <ws> \
--cluster <cluster-key> \
--code "spark.sql('''SELECT COUNT(*) AS v FROM cat.sch.t WHERE col IS NULL''').show()"
It mints a UPST from the api_key DEFAULT profile, auto-creates a scratch notebook, and returns JSON with
status / outputs / spark_job_ids. No AIDP_SESSION required (--session-profile optional).LIMIT query.aidp-pipelines) as a gating task.Register validated rules in .aidp/dq-rules.md so they can be re-run later (the quality analogue of
.aidp/verified-queries.md). One entry per rule records the target table/column, rule-type (the five types
above), the violation-SQL (counts violations → PASS when 0), and last-result / last-checked. To
re-run, execute each entry's stored violation-SQL via scripts/aidp_sql.py, set the result to PASS (0) or
FAIL (<count>), and record the cluster + date — never mark PASS without a status: ok run returning 0.
Format and re-run rules: references/dq-rules.md.
scripts/aidp_sql.py; never assert a rule passed without a status: ok result.status: error, read the error, fix the SQL grounded in the catalog, and retry..aidp/dq-rules.md rule-set format + re-run)原文・著作権は Anthropic および各プラグイン作者に帰属します。日本語訳は Claude API による自動翻訳です。