Model-level data retention (TTL): automatically delete rows older than N days
Maintainer antworten meist innerhalb von 4 Tagen
Dieses Issue hat noch niemand übernommen.
Bewertung
- Schwierigkeit
- 5/5
- Geschätzter Aufwand
- Über eine Woche
- Anfängerfreundlichkeit
- 15/100
- Issue-Typ
- Feature
- Klarheit
- Größtenteils klar
- Aktivitätsstatus
- Aktiv
- Bereich
- data-engineering
Rechercherichtung
The payload names no source files. Start from how the MODEL definition's options are parsed and how incremental kinds such as INCREMENTAL_BY_TIME_RANGE declare their time_column, then look at where post-materialization statements run. Done would need a design agreed with maintainers covering engine-specific deletion (DELETE versus partition drop) and re-enforcement after full refreshes, which the issue leaves open.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Beschreibung
Is your feature request related to a problem?
Incremental models accumulate history forever. There is no native way to express "keep the last N days" for a model's physical table:
startonINCREMENTAL_BY_TIME_RANGE/INCREMENTAL_BY_RANGEbounds what gets processed going forward, but nothing ever removes old data.- The janitor only cleans SQLMesh's own metadata (snapshots, environments), not rows in model tables.
- Warehouse-native mechanisms don't cover this: on Snowflake,
DATA_RETENTION_TIME_IN_DAYSonly controls Time Travel, it does not expire rows from the live table; other engines have no equivalent at all.
Workarounds and why they fall short
- Filter in the model query (
WHERE event_ts >= CURRENT_DATE - 30): new old rows never land, but rows written before the filter was added stay until a full rebuild, and backfills against full-history sources silently recompute only the window. - External cleanup task (
DELETE FROM ... WHERE event_ts < ...from the orchestrator or a hand-rolled model): works, but retention lives outside the model definition. A breaking change and full refresh of the model resurrects the old rows, and there is nothing in the plan diff that tells a reviewer the table has a retention policy attached.
Proposed solution
A model-level retention/TTL option, e.g.:
MODEL (
name analytics.events,
kind INCREMENTAL_BY_TIME_RANGE (
time_column event_ts
),
retention 30 days
);
SQLMesh would enforce it by issuing a DELETE on the time column after materialization (or, on engines that support it, dropping whole partitions/files). Key properties that make it a feature rather than a snippet:
- Declarative and visible in the model definition and plan diffs.
- Applied automatically after full refreshes/backfills, so rebuilding a model can never resurrect expired rows.
- Engine-aware: partition drop where available (e.g. Iceberg),
DELETEelsewhere.
Alternatives considered
A documented macro recipe or a post statement doing the DELETE. We already do this today, but it is invisible in the plan, easy to forget in new models, and re-runs/full refreshes don't re-enforce it.
Environment
- Open-source SQLMesh with Snowflake as the main engine, orchestrated via Airflow.
- Vorherrschende Sprache
- Python
- Sterne
- 3.3k
- Forks
- 471
- Ø Merge
- 6 T. 7 Std.
- Gemergte PRs (30 T.)
- 35
Entwicklungsumgebung
Startet den Dev-Container des Projekts im Browser, mit Ihrem eigenen GitHub-Konto.
- Kein Dockerfile und keine Docker-Compose-Datei
- Hat eine Pull-Request-Vorlage
- Beitragsleitfaden lesen
Erste Schritte
- Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
- Forken Sie das Repository und arbeiten Sie in einem Branch.
- Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.
Mehr aus SQLMesh/sqlmesh
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 86/100
Maintainer antworten meist innerhalb von 4 Tagen
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 68/100
Maintainer antworten meist innerhalb von 4 Tagen
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 67/100
SQLMesh/sqlmesh#6008 · 1 Kommentar ·
Maintainer antworten meist innerhalb von 4 Tagen
-
VSCode Extension: SQLMesh LSP crashes on startup: ImportError: cannot import name 'WorkspaceDiagnosticRefreshRequest' with lsprotocol 2025.xEvtl. vergeben @boomesh11 hat das vor 15 Tagen übernommen. OffenBug
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 66/100
Maintainer antworten meist innerhalb von 4 Tagen
-
Improvement
Schwierigkeit 1/5 Unter einer Stunde Anfängerfreundlichkeit 85/100
SQLMesh/sqlmesh#5696 · 6 Kommentare ·
Maintainer antworten meist innerhalb von 4 Tagen
Alle Issues in SQLMesh/sqlmesh
Ähnliche Issues
-
[BUG][Low–Medium] founder_numbers.py silently reads a SAFE discount or pool target given as a fraction (0.2) as 0.2%Evtl. vergeben @sumitkhond111-del hat das heute übernommen. Offenbug
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 72/100
bmad-code-org/BMAD-METHOD#3358 · 1 Kommentar ·
Maintainer antworten meist innerhalb von 1 Tag
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 86/100
open-mmlab/mmcv#3352 ·
-
Schwierigkeit 1/5 Unter einer Stunde Anfängerfreundlichkeit 68/100
OpenGithubs/weekly#263 ·
Maintainer antworten meist innerhalb von 1 Tag
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 76/100
Maintainer antworten meist innerhalb von 1 Tag
-
comp/cli P3 type/feature
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 76/100
NousResearch/hermes-agent#162784 ·
Maintainer antworten meist innerhalb von 1 Tag