Model-level data retention (TTL): automatically delete rows older than N days
Los mantenedores suelen responder en 4 días
Nadie ha tomado este issue todavía.
Evaluación
- Dificultad
- 5/5
- Tiempo estimado
- Más de una semana
- Aptitud para principiantes
- 15/100
- Tipo de issue
- Nueva funcionalidad
- Claridad
- Bastante claro
- Estado de actividad
- Activo
- Área
- data-engineering
Línea de trabajo
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.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
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.
- Lenguaje dominante
- Python
- Estrellas
- 3.3k
- Forks
- 471
- Merge medio
- 6 d 7 h
- PR fusionados (30 d)
- 35
Preparar el entorno
Inicia el contenedor de desarrollo del proyecto en tu navegador, con tu propia cuenta de GitHub.
- Sin Dockerfile ni archivo de Docker Compose
- Tiene una plantilla de pull request
- Leer la guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de SQLMesh/sqlmesh
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 86/100
Los mantenedores suelen responder en 4 días
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 68/100
Los mantenedores suelen responder en 4 días
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 67/100
SQLMesh/sqlmesh#6008 · 1 comentario ·
Los mantenedores suelen responder en 4 días
-
VSCode Extension: SQLMesh LSP crashes on startup: ImportError: cannot import name 'WorkspaceDiagnosticRefreshRequest' with lsprotocol 2025.xPosiblemente ocupada @boomesh11 la tomó hace 15 días. AbiertoBug
Dificultad 2/5 1-3 horas Aptitud para principiantes 66/100
Los mantenedores suelen responder en 4 días
-
Improvement
Dificultad 1/5 Menos de una hora Aptitud para principiantes 85/100
SQLMesh/sqlmesh#5696 · 6 comentarios ·
Los mantenedores suelen responder en 4 días
Todos los issues de SQLMesh/sqlmesh
Issues similares
-
[BUG][Low–Medium] founder_numbers.py silently reads a SAFE discount or pool target given as a fraction (0.2) as 0.2%Posiblemente ocupada @sumitkhond111-del la tomó hoy. Abiertobug
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
bmad-code-org/BMAD-METHOD#3358 · 1 comentario ·
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 86/100
open-mmlab/mmcv#3352 ·
-
Dificultad 1/5 Menos de una hora Aptitud para principiantes 68/100
OpenGithubs/weekly#263 ·
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 76/100
Los mantenedores suelen responder en 1 día
-
comp/cli P3 type/feature
Dificultad 2/5 1-3 horas Aptitud para principiantes 76/100
NousResearch/hermes-agent#162784 ·
Los mantenedores suelen responder en 1 día