martin-g commented on code in PR #24655:
URL: https://github.com/apache/datafusion/pull/24655#discussion_r3878846226
##########
datafusion/catalog/src/memory/table.rs:
##########
@@ -361,71 +363,24 @@ impl MemTable {
state: &'a dyn Session,
filters: Vec<Expr>,
) -> BoxFuture<'a, Result<Arc<dyn ExecutionPlan>>> {
- Box::pin(self.delete_from_inner(state, filters))
+ Box::pin(ready(self.plan_delete(state, filters)))
}
- async fn delete_from_inner(
+ /// Build the plan of a DELETE. The rows change when the plan runs, not
here.
+ fn plan_delete(
&self,
state: &dyn Session,
filters: Vec<Expr>,
) -> Result<Arc<dyn ExecutionPlan>> {
// Early exit if table has no partitions
if self.batches.is_empty() {
- return Ok(Arc::new(DmlResultExec::new(0)));
+ return Ok(self.dml_exec(vec![], vec![], MemDmlOp::Delete));
Review Comment:
Please ignore! It seems to work as desired:
```
❯ create table t2(a int, b varchar, c double, d int);
0 row(s) fetched.
Elapsed 0.009 seconds.
❯ EXPLAIN DELETE FROM t2 WHERE nonexistent = 1;
Diagnostic(Diagnostic { kind: Error, message: "column 'nonexistent' not
found", span: None, notes: [], helps: [] }, SchemaError(FieldNotFound { field:
Column { relation: None, name: "nonexistent" }, valid_fields: [Column {
relation: Some(Bare { table: "t2" }), name: "a" }, Column { relation: Some(Bare
{ table: "t2" }), name: "b" }, Column { relation: Some(Bare { table: "t2" }),
name: "c" }, Column { relation: Some(Bare { table: "t2" }), name: "d" }] },
Some("")))
❯ DELETE FROM t2 WHERE nonexistent = 1;
Diagnostic(Diagnostic { kind: Error, message: "column 'nonexistent' not
found", span: None, notes: [], helps: [] }, SchemaError(FieldNotFound { field:
Column { relation: None, name: "nonexistent" }, valid_fields: [Column {
relation: Some(Bare { table: "t2" }), name: "a" }, Column { relation: Some(Bare
{ table: "t2" }), name: "b" }, Column { relation: Some(Bare { table: "t2" }),
name: "c" }, Column { relation: Some(Bare { table: "t2" }), name: "d" }] },
Some("")))
❯ EXPLAIN ANALYZE DELETE FROM t2 WHERE nonexistent = 1;
Diagnostic(Diagnostic { kind: Error, message: "column 'nonexistent' not
found", span: None, notes: [], helps: [] }, SchemaError(FieldNotFound { field:
Column { relation: None, name: "nonexistent" }, valid_fields: [Column {
relation: Some(Bare { table: "t2" }), name: "a" }, Column { relation: Some(Bare
{ table: "t2" }), name: "b" }, Column { relation: Some(Bare { table: "t2" }),
name: "c" }, Column { relation: Some(Bare { table: "t2" }), name: "d" }] },
Some("")))
❯
```
I must have done something wrong yesterday.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]