UPDATE / DELETE fail with "No field named __common_expr_1" when SET or WHERE repeats an expression
Los mantenedores suelen responder en 1 día
Evaluación
- Dificultad
- 4/5
- Tiempo estimado
- 3-5 días
- Aptitud para principiantes
- 20/100
- Tipo de issue
- Error
- Claridad
- Bien especificado
- Estado de actividad
- Estancado
- Stack tecnológico
- rust
- Área
- backend-api-design, databases
Línea de trabajo
Start by tracing extract_update_assignments and extract_dml_filters in the physical planner, then follow how common subexpression elimination moves expressions into projections. Check the UPDATE and DELETE planning paths against the table provider's schema. Done means the three reproduced statements execute without the missing __common_expr_N schema error and produce the expected row changes.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
Describe the bug
An UPDATE or DELETE on an in-memory table fails at planning time with a schema error regarding an internal column when its SET expressions or WHERE clause contain the same expression more than once (for example, COALESCE(c0, 0) on an INT column, where the column is coerced/cast to Int64 twice to match the integer literal):
UPDATE operation on table 't' caused by Schema error: No field named __common_expr_1. Valid fields are c0, c1.
Common subexpression elimination moves the repeated expression into an underlying projection below the UPDATE assignment projection (or below the Filter node). When the physical planner extracts the assignments (extract_update_assignments) and filters (extract_dml_filters) and hands them to the table provider, the provider evaluates them directly against the table's schema, where __common_expr_1 does not exist.
To Reproduce
CREATE TABLE t (c0 INT, c1 VARCHAR);
INSERT INTO t VALUES (1, 'a'), (NULL, 'b');
UPDATE t SET c0 = COALESCE(c0, 0); -- Schema error: No field named __common_expr_1
UPDATE t SET c1 = 'z' WHERE COALESCE(c0, 0) > 0 AND COALESCE(c0, 0) < 5; -- Schema error: No field named __common_expr_N
DELETE FROM t WHERE COALESCE(c0, 0) > 0 AND COALESCE(c0, 0) < 5; -- Schema error: No field named __common_expr_N
Expected behavior
The first UPDATE should update 2 rows ((1, 'a'), (0, 'b')). The second UPDATE should update 1 row, and the DELETE should delete 1 row. The same expressions execute without error in a SELECT.
Additional context
Reproduced on main at commit bc86321 (57.0.0-dev) and with datafusion-python 55.0.0. Found via an automated SQL fuzzer comparing execution plans.
Willingness to contribute
I plan to contribute a fix for this bug independently
- Lenguaje dominante
- Rust
- Estrellas
- 9.6k
- Forks
- 2.6k
- Merge medio
- 3 d 4 h
- PR fusionados (30 d)
- 345
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 apache/datafusion
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
apache/datafusion#27315 · 2 comentarios ·
Los mantenedores suelen responder en 1 día
-
bug
Dificultad 2/5 1-3 horas Aptitud para principiantes 76/100
apache/datafusion#27094 · 1 comentario ·
Los mantenedores suelen responder en 1 día
-
Substrait consumer doesn't recognise `shift_left` / `shift_right` from functions_arithmetic.yamlPosiblemente ocupada @jonasHanhan la tomó hace 9 días. Abiertobug
Dificultad 2/5 1-3 horas Aptitud para principiantes 76/100
apache/datafusion#27059 ·
Los mantenedores suelen responder en 1 día
-
`ProjectionExprs::project_statistics` computes approximate `Statistics::total_byte_size` ignoring column statsPosiblemente ocupada @joseph-isaacs la tomó hace 10 días. Abiertobug
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
apache/datafusion#27050 ·
Los mantenedores suelen responder en 1 día
-
physical-plan: decoding an Unnest or Explain node with an unset field panicsPosiblemente ocupada @geoHeil la tomó hace 8 días. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 75/100
apache/datafusion#26999 · 1 comentario ·
Los mantenedores suelen responder en 1 día
Todos los issues de apache/datafusion
Issues similares
-
area:schema documentation
Dificultad 2/5 1-3 horas Aptitud para principiantes 76/100
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 82/100
ElectronicWave/Elemental#252 ·
Los mantenedores suelen responder en 1 día
-
bug
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
dekobon/big-code-analysis#1887 ·
Los mantenedores suelen responder en 1 día
-
Shell中文符号输入异常Abiertobug
Dificultad 2/5 1-3 horas Aptitud para principiantes 76/100
Los mantenedores suelen responder en 1 día
-
Dificultad 1/5 Menos de una hora Aptitud para principiantes 82/100
Los mantenedores suelen responder en 1 día