RFC: persist audit results to a warehouse table
Les mainteneurs répondent en général sous 4 jours
Personne n'a encore pris cette issue.
Évaluation
- Difficulté
- 5/5
- Temps estimé
- Plus d'une semaine
- Accessibilité débutants
- 32/100
- Type d'issue
- Fonctionnalité
- Clarté
- Clairement spécifiée
- Activité
- Active
- Domaine
- data-engineering, databases
Piste de recherche
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.
Rédigé par le modèle d'indexation à partir du texte de l'issue.
Description
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.
- Langage dominant
- Python
- Étoiles
- 3.3k
- Forks
- 471
- Merge moyen
- 6 j 7 h
- PR mergées (30 j)
- 35
Préparer son environnement
Lance le conteneur de développement du projet dans votre navigateur, avec votre propre compte GitHub.
- Aucun Dockerfile ni fichier Docker Compose
- Propose un modèle de pull request
- Lire le guide de contribution
Par où commencer
- Lisez l'issue en entier, puis le guide de contribution du projet.
- Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
- Forkez le dépôt et travaillez sur une branche.
- Ouvrez une pull request qui référence le numéro de l'issue.
Autres issues de SQLMesh/sqlmesh
-
Difficulté 2/5 1-3 heures Accessibilité débutants 86/100
Les mainteneurs répondent en général sous 4 jours
-
Difficulté 2/5 1-3 heures Accessibilité débutants 68/100
Les mainteneurs répondent en général sous 4 jours
-
Difficulté 2/5 1-3 heures Accessibilité débutants 67/100
SQLMesh/sqlmesh#6008 · 1 commentaire ·
Les mainteneurs répondent en général sous 4 jours
-
VSCode Extension: SQLMesh LSP crashes on startup: ImportError: cannot import name 'WorkspaceDiagnosticRefreshRequest' with lsprotocol 2025.xPeut-être pris @boomesh11 l’a pris il y a 15 jours. OuverteBug
Difficulté 2/5 1-3 heures Accessibilité débutants 66/100
Les mainteneurs répondent en général sous 4 jours
-
Improvement
Difficulté 1/5 Moins d'une heure Accessibilité débutants 85/100
SQLMesh/sqlmesh#5696 · 6 commentaires ·
Les mainteneurs répondent en général sous 4 jours
Toutes les issues de SQLMesh/sqlmesh
Issues similaires
-
accepted
Difficulté 2/5 1-3 heures Accessibilité débutants 67/100
future-agi/future-agi#5274 ·
Les mainteneurs répondent en général sous 1 jour
-
Difficulté 2/5 1-3 heures Accessibilité débutants 78/100
GenericMappingTools/pygmt#5014 · 1 commentaire ·
Les mainteneurs répondent en général sous 1 jour
-
Feed validator crashes with "Memory error" when validating https://www.tidyverse.org/index.xmlOuvertebug
Difficulté 2/5 1-3 heures Accessibilité débutants 66/100
w3c/feedvalidator#204 ·
-
[BUG][Low–Medium] founder_numbers.py silently reads a SAFE discount or pool target given as a fraction (0.2) as 0.2%Peut-être pris @sumitkhond111-del l’a pris aujourd’hui. Ouvertebug
Difficulté 2/5 1-3 heures Accessibilité débutants 72/100
bmad-code-org/BMAD-METHOD#3358 · 1 commentaire ·
Les mainteneurs répondent en général sous 1 jour
-
Difficulté 2/5 1-3 heures Accessibilité débutants 86/100
open-mmlab/mmcv#3352 ·