Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

UPDATE statment for non existent column doesn't error out #5068

Closed
gruuya opened this issue Jan 25, 2023 · 0 comments · Fixed by #5069
Closed

UPDATE statment for non existent column doesn't error out #5068

gruuya opened this issue Jan 25, 2023 · 0 comments · Fixed by #5069
Labels
bug Something isn't working

Comments

@gruuya
Copy link
Contributor

gruuya commented Jan 25, 2023

Describe the bug
When the new LogicalPlan::Dml node for the UPDATE SQL statement is being generated during logical planning, the existence of the assignment target columns is never checked (unlike the existence of the assignment expression and selection expression columns).

To Reproduce

cd datafusion-cli
cargo run
...
❯ create table person (age int) as values (35);
0 rows in set. Query took 0.056 seconds.
❯ select * from person;
+-----+
| age |
+-----+
| 35  |
+-----+
1 row in set. Query took 0.017 seconds.
❯ update person set nonexistent = 36;
Internal("Unsupported logical plan: Dml")
❯ update person set age = 36 where nonexistent = true;
SchemaError(FieldNotFound { field: Column { relation: None, name: "nonexistent" }, valid_fields: [Column { relation: None, name: "age" }] })
❯ update person set age = (nonexistent + 1);
SchemaError(FieldNotFound { field: Column { relation: None, name: "nonexistent" }, valid_fields: [Column { relation: None, name: "age" }] })

The Unsupported logical plan: Dml comes from the physical planning phase. In other words the logical plane has been created successfully.

Expected behavior
Target column existence should be checked during logical planning and the FieldNotFound error should be thrown when the column is missing. Otherwise a typo will result in a valid logical plan, which when executed will not contain the changes the user intends/assumes.

Additional context
None

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant