RFC: persist audit results to a warehouse table
メンテナーはふだん 4 日以内に返信
まだ誰も着手していません。
評価
- 難易度
- 5/5
- 見積もり時間
- 1週間以上
- 初心者へのやさしさ
- 32/100
- issue の種類
- 機能追加
- 明瞭さ
- 明確に書かれている
- 活発さ
- 活発
調査の方向性
Start with SnapshotEvaluator.audit, Scheduler._audit_snapshot, run_merged_intervals, create_state_table, and the audit-results configuration and janitor entry points. The RFC proposes separate work for the completion callback, recorder buffering and flushing, wiring into plan, run, and sqlmesh audit, retention, documentation, and engine-adapter integration tests. A newcomer should not begin implementation until the open questions about strict versus warn-only failures, table naming and location, error recording, and schema reuse are resolved.
索引モデルが issue の本文から書いたものです。
説明
RFC: persist audit results to a warehouse table
This revisits #3064. It was closed because Tobiko Cloud covered it. Now that Cloud is discontinued, I'd like to contribute an open-source version. Below are a proposed design and PR breakdown. Please push back on anything before I start.
Goal
Opt in to one summary row per audit execution, written to a table in the warehouse. Teams can then build audit history and data-quality dashboards with plain SQL. Today the only option is a custom GenericNotificationTarget. It sees failures only, and it gets no interval, environment or run context.
Out of scope: storing failing rows, as dbt's store_failures does. Only the summary is stored: status, failing-row count, and the rendered query.
Config
audit_results:
enabled: true # default false
gateway: warehouse # default: the selected gateway
table: sqlmesh.audit_results # default
include_query: true # store the rendered audit SQL
retention: 4 weeks # optional; enforced by the janitor
Table
There is one row per audit execution, for plans, runs and sqlmesh audit, in both prod and dev. Timestamps are epoch-ms BIGINT, as in the state tables. There is no primary key.
| Column(s) | Contents |
|---|---|
id, recorded_ts, started_ts, duration_ms |
Row id and timing |
job_type (plan / run / audit), job_id |
Which job ran the audit. job_id is the plan id, or the run id from the existing CorrelationId. |
environment, gateway, is_dev |
Where it ran |
node_name, node_type (model / standalone_audit), snapshot_identifier, snapshot_version |
What was audited. snapshot_identifier joins to _snapshots. |
audit_name, audit_args (JSON), blocking |
Which audit. blocking is the resolved value, including force_non_blocking. |
status (passed / failed / skipped / error), failed_row_count, error_message |
The outcome. error means the audit query itself raised. |
query, query_dialect |
The rendered SQL, in the dialect of the gateway it ran on (truncated) |
interval_start_ts, interval_end_ts, execution_ts |
Which data was audited |
sqlmesh_version |
Schema evolution: columns are additive only. On first use SQLMesh creates the table, or adds any missing columns. It uses create_state_table, which gives Athena an Iceberg table and drops the primary key on BigQuery.
Design
- Capture:
- A keyword-only
on_audit_completecallback onSnapshotEvaluator.auditreceives an outcome for every audit, including audits whose query raised, along with its duration. Scheduler._audit_snapshotbinds the context: job, environment and interval.- Rows are buffered before
NodeAuditsErrorsis raised. - The execution observer from #6051 is unchanged.
- A keyword-only
- Write:
- Rows are buffered thread-safely.
- The buffer is flushed with one
insert_appendin the outerfinallyofrun_merged_intervals, plus an early flush every ~1,000 rows. That gives one load per run rather than one per model, which matters for BigQuery's load-job quotas. - The write runs outside any model, state or WAP transaction.
- Failure semantics (the main open question):
- Persisting is strict: if it's enabled and the write fails, the job fails.
- A pre-flight check creates or verifies the table before any model work, so a missing permission fails fast instead of after a long backfill.
- A write failure never masks an error that is already being raised; it is attached as a note instead.
- I'm happy to switch to warn-only, or to add
fail_on_error(default true), if you'd prefer that observability never fails a run.
- Retention: when
retentionis set, the janitor deletes old rows. - Known gaps (to be documented):
- A hard kill loses the buffer.
- Audits skipped because an upstream node failed are not recorded.
PR plan
Each PR is small and lands independently on main. Everything is inert until PR 5 wires it in, behind enabled: false.
fix(audit): render audit errors in the executing gateway's dialect. This is an independent existing bug: errors currently use the default gateway's dialect.feat(audit): contract types and table schema.feat(config): theaudit_resultsconfig section.feat(evaluator): per-audit completion hook. No behaviour change.feat(audit):AuditResultsRecorder(buffer, ensure table, flush).feat: wire it into plan, run andsqlmesh audit, plus docs.feat(janitor): retention.test: engine-adapter integration coverage.
Points I'd especially like your view on:
- strict failure versus warn-only;
- the table name and default location;
- recording
errorstatus; - reusing
create_state_tablefor a table that isn't state; - whether you'd rather fold PRs 2–5 into fewer PRs.
- 主要言語
- Python
- スター
- 3.3k
- フォーク
- 471
- 平均マージ
- 6日 7時間
- マージ済み PR(30日)
- 35
環境構築
このプロジェクトの開発コンテナを、あなたの GitHub アカウントでブラウザ上に起動します。
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートあり
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
SQLMesh/sqlmesh のほかの issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 86/100
メンテナーはふだん 4 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
メンテナーはふだん 4 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 67/100
SQLMesh/sqlmesh#6008 · コメント 1 件 ·
メンテナーはふだん 4 日以内に返信
-
VSCode Extension: SQLMesh LSP crashes on startup: ImportError: cannot import name 'WorkspaceDiagnosticRefreshRequest' with lsprotocol 2025.x対応中かも @boomesh11 が 15 日前に担当しました。 オープンBug
難易度 2/5 1〜3時間 初心者へのやさしさ 66/100
メンテナーはふだん 4 日以内に返信
-
Improvement
難易度 1/5 1時間未満 初心者へのやさしさ 85/100
SQLMesh/sqlmesh#5696 · コメント 6 件 ·
メンテナーはふだん 4 日以内に返信
SQLMesh/sqlmesh の issue をすべて見る
似ている issue
-
[BUG][Low–Medium] founder_numbers.py silently reads a SAFE discount or pool target given as a fraction (0.2) as 0.2%対応中かも @sumitkhond111-del が今日担当しました。 オープンbug
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
bmad-code-org/BMAD-METHOD#3358 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 86/100
open-mmlab/mmcv#3352 ·
-
難易度 1/5 1時間未満 初心者へのやさしさ 68/100
OpenGithubs/weekly#263 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
メンテナーはふだん 1 日以内に返信
-
comp/cli P3 type/feature
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
NousResearch/hermes-agent#162784 ·
メンテナーはふだん 1 日以内に返信