UPDATE / DELETE fail with "No field named __common_expr_1" when SET or WHERE repeats an expression
Les mainteneurs répondent en général sous 1 jour
Évaluation
- Difficulté
- 4/5
- Temps estimé
- 3-5 jours
- Accessibilité débutants
- 20/100
- Type d'issue
- Bug
- Clarté
- Clairement spécifiée
- Activité
- À l'abandon
- Stack technique
- rust
- Domaine
- backend-api-design, databases
Piste de recherche
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.
Rédigé par le modèle d'indexation à partir du texte de l'issue.
Description
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
- Langage dominant
- Rust
- Étoiles
- 9.6k
- Forks
- 2.6k
- Merge moyen
- 3 j 4 h
- PR mergées (30 j)
- 345
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 apache/datafusion
-
Difficulté 2/5 1-3 heures Accessibilité débutants 72/100
apache/datafusion#27315 · 2 commentaires ·
Les mainteneurs répondent en général sous 1 jour
-
bug
Difficulté 2/5 1-3 heures Accessibilité débutants 76/100
apache/datafusion#27094 · 1 commentaire ·
Les mainteneurs répondent en général sous 1 jour
-
Substrait consumer doesn't recognise `shift_left` / `shift_right` from functions_arithmetic.yamlPeut-être pris @jonasHanhan l’a pris il y a 9 jours. Ouvertebug
Difficulté 2/5 1-3 heures Accessibilité débutants 76/100
apache/datafusion#27059 ·
Les mainteneurs répondent en général sous 1 jour
-
`ProjectionExprs::project_statistics` computes approximate `Statistics::total_byte_size` ignoring column statsPeut-être pris @joseph-isaacs l’a pris il y a 10 jours. Ouvertebug
Difficulté 2/5 1-3 heures Accessibilité débutants 72/100
apache/datafusion#27050 ·
Les mainteneurs répondent en général sous 1 jour
-
physical-plan: decoding an Unnest or Explain node with an unset field panicsPeut-être pris @geoHeil l’a pris il y a 8 jours. Ouverte
Difficulté 2/5 1-3 heures Accessibilité débutants 75/100
apache/datafusion#26999 · 1 commentaire ·
Les mainteneurs répondent en général sous 1 jour
Toutes les issues de apache/datafusion
Issues similaires
-
P3
Difficulté 2/5 1-3 heures Accessibilité débutants 70/100
HerringtonDarkholme/hd-lang#1770 ·
Les mainteneurs répondent en général sous 1 jour
-
Difficulté 2/5 1-3 heures Accessibilité débutants 82/100
jonathanong/no-mistakes#3332 ·
Les mainteneurs répondent en général sous 1 jour
-
bug
Difficulté 2/5 1-3 heures Accessibilité débutants 78/100
swc-project/swc-next-issues#310 ·
-
bug
Difficulté 2/5 1-3 heures Accessibilité débutants 72/100
swc-project/swc-ai-issues#653 ·
-
Difficulté 2/5 1-3 heures Accessibilité débutants 72/100
lbjlaq/Antigravity-Manager#3937 ·
Les mainteneurs répondent en général sous 1 jour