Table materialization (V2) leads to unavailability of data
Los mantenedores suelen responder en 6 días
Nadie ha tomado este issue todavía.
Evaluación
- Dificultad
- 5/5
- Tiempo estimado
- Más de una semana
- Aptitud para principiantes
- 42/100
Línea de trabajo
Comienza con docs/table_flow.md y reproduce el fallo usando el modelo toto.sql, el contrato toto.yml y los dos comandos dbt run. Compara el flujo de materialización de la tabla con la estrategia insert_overwrite mencionada; se considera terminado cuando una ejecución con restricciones que falla no elimina los datos existentes válidos y la tabla sigue disponible.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
Describe the bug
TLDR; stop using create or replace and then insert when table when table already exists (with valid data)
Two problems since materialization V2 for "table":
- The table materialization does 2 steps (create or replace + insert) that can lead to an unavailability of the data
- Constraints can be applied before hands (thanks a lot!) but the problem is that if new data arrive violating the said constraints afterward, we recreate the table first, hence removing all data.
The problem is that Delta is not handling transactions across multiple commands... One way to do overcome the second problem would be to add a clause for putting back data using RESTORE but it leaves the first problem.
Then, I thought of using the insert_overwrite incremental strategy that would replace all data in a single transaction, hence not removing existing valid data in a violation constraint scenario but the strategy isn't complete yet (not possible to add columns if I read right) and unavailable for SQL warehouse (even though I don't understand why because here would be a valid case for overwriting completely the table, maybe should have been only a warning in the logs?).
I think using insert_overwrite (without partition predicate) in the table materialization when the relation already exists in the database would be an idea but this may lead to complications (what if a column type changes ?). Happy to discuss !
Steps To Reproduce
Create a model toto.sql :
{{
config(
materialized = 'table',
)
}}
{% if load_relation(this) %} {# meaning it exists in the database #}
select null as name
union all
select 'toto' as name
{% else %} {# meaning it does not exist in the database #}
select 'toto' as name
{% endif %}
And its corresponding toto.yml
models:
- name: toto
config:
contract:
enforced: true
columns:
- name: name
data_type: string
constraints:
- type: not_null
Then run :
dbt run -s toto --> Succeed + select * from my_catalog.my_schema.toto returns 1 row
dbt run -s toto --> Fails + select * from my_catalog.my_schema.toto returns 0 row
Expected behavior
I want my valid data not to be removed and a 0 downtime of my table.
System information
The output of dbt --version:
Core:
- installed: 1.10.2
- latest: 1.10.5 - Update available!
Your version of dbt-core is out of date!
You can find instructions for upgrading here:
https://docs.getdbt.com/docs/installation
Plugins:
- databricks: 1.10.4 - Up to date!
- spark: 1.9.2 - Update available!
At least one plugin is out of date with dbt-core.
You can find instructions for upgrading here:
https://docs.getdbt.com/docs/installation
The operating system you're using:
Mac OS
The output of python --version:
Python 3.13.5
Additional context
Thanks everyone for all the good work !! 🙏 I would be glad to contribute once we decide how to handle this problem ! Don't hesitate to reach out, we can even schedule a call if you have time for this.
- Lenguaje dominante
- Python
- Estrellas
- 391
- Forks
- 231
- Merge medio
- 9 d 7 h
- PR fusionados (30 d)
- 29
Preparar el entorno
- 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 databricks/dbt-databricks
-
persist_docs.columns triggers a full-plan probe query on views even when the model has no column docsPosiblemente ocupada @DelorneN007 la tomó hace 59 días. Abiertobug
Dificultad 2/5 1-3 horas Aptitud para principiantes 85/100
databricks/dbt-databricks#1680 · 1 comentario ·
Los mantenedores suelen responder en 6 días
-
bug
Dificultad 2/5 Medio día Aptitud para principiantes 68/100
databricks/dbt-databricks#1003 · 1 comentario ·
Los mantenedores suelen responder en 6 días
-
Emit COMMENT and DEFAULT for function arguments and descriptions in CREATE FUNCTIONPosiblemente ocupada @alvinism la tomó hace 7 días. Abiertoenhancement
Dificultad 4/5 3-5 días Aptitud para principiantes 25/100
databricks/dbt-databricks#1764 ·
Los mantenedores suelen responder en 6 días
-
bug
Dificultad 4/5 3-5 días Aptitud para principiantes 46/100
databricks/dbt-databricks#1762 ·
Los mantenedores suelen responder en 6 días
-
Dificultad 4/5 3-5 días Aptitud para principiantes 45/100
databricks/dbt-databricks#1761 ·
Los mantenedores suelen responder en 6 días
Todos los issues de databricks/dbt-databricks
Issues similares
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 67/100
FinanceFlash/unvibecode#699 ·
Los mantenedores suelen responder en 1 día
-
enhancement Website
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
OWASP/OWASP-Hunting#96 ·
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
micropython/micropython#19942 ·
Los mantenedores suelen responder en 1 día
-
A rebuild posts "not part of this build" success to the commit's failed `nix-build` gate and effectsPosiblemente ocupada @Padraic-O-Mhuiris la tomó hoy. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
Los mantenedores suelen responder en 1 día
-
`epoch.Integer` raises a raw OverflowError for integers too large to convert to a floatPosiblemente ocupada @arindam77 la tomó hoy. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
pydantic/pydantic-extra-types#479 ·
Los mantenedores suelen responder en 1 día