Skip to content

Commit b038d04

Browse files
committed
fix: Use assert!() for bool assertions and update expected DML errors
- Change assert_eq!(x, true/false) to assert!(x)/assert!(!x) per clippy - Update delete.slt and update.slt expected error messages to match new physical planner behavior for unsupported DML operations
1 parent 30d98c5 commit b038d04

File tree

3 files changed

+20
-20
lines changed

3 files changed

+20
-20
lines changed

datafusion/expr/src/logical_plan/dml.rs

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -356,25 +356,25 @@ mod tests {
356356

357357
#[test]
358358
fn test_dml_capabilities_constants() {
359-
assert_eq!(DmlCapabilities::NONE.delete, false);
360-
assert_eq!(DmlCapabilities::NONE.update, false);
359+
assert!(!DmlCapabilities::NONE.delete);
360+
assert!(!DmlCapabilities::NONE.update);
361361

362-
assert_eq!(DmlCapabilities::ALL.delete, true);
363-
assert_eq!(DmlCapabilities::ALL.update, true);
362+
assert!(DmlCapabilities::ALL.delete);
363+
assert!(DmlCapabilities::ALL.update);
364364

365-
assert_eq!(DmlCapabilities::DELETE_ONLY.delete, true);
366-
assert_eq!(DmlCapabilities::DELETE_ONLY.update, false);
365+
assert!(DmlCapabilities::DELETE_ONLY.delete);
366+
assert!(!DmlCapabilities::DELETE_ONLY.update);
367367

368-
assert_eq!(DmlCapabilities::UPDATE_ONLY.delete, false);
369-
assert_eq!(DmlCapabilities::UPDATE_ONLY.update, true);
368+
assert!(!DmlCapabilities::UPDATE_ONLY.delete);
369+
assert!(DmlCapabilities::UPDATE_ONLY.update);
370370
}
371371

372372
#[test]
373373
fn test_dml_capabilities_supports_any() {
374-
assert_eq!(DmlCapabilities::NONE.supports_any(), false);
375-
assert_eq!(DmlCapabilities::ALL.supports_any(), true);
376-
assert_eq!(DmlCapabilities::DELETE_ONLY.supports_any(), true);
377-
assert_eq!(DmlCapabilities::UPDATE_ONLY.supports_any(), true);
374+
assert!(!DmlCapabilities::NONE.supports_any());
375+
assert!(DmlCapabilities::ALL.supports_any());
376+
assert!(DmlCapabilities::DELETE_ONLY.supports_any());
377+
assert!(DmlCapabilities::UPDATE_ONLY.supports_any());
378378
}
379379

380380
#[test]

datafusion/sqllogictest/test_files/delete.slt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ explain delete from t1;
3434
logical_plan
3535
01)Dml: op=[Delete] table=[t1]
3636
02)--TableScan: t1
37-
physical_plan_error This feature is not implemented: Unsupported logical plan: Dml(Delete)
37+
physical_plan_error Error during planning: Table 't1' does not support DELETE operations
3838

3939

4040
# Filtered by existing columns
@@ -45,7 +45,7 @@ logical_plan
4545
01)Dml: op=[Delete] table=[t1]
4646
02)--Filter: CAST(t1.a AS Int64) = Int64(1) AND t1.b = CAST(Int64(2) AS Utf8View) AND t1.c > CAST(Int64(3) AS Float64) AND CAST(t1.d AS Int64) != Int64(4)
4747
03)----TableScan: t1
48-
physical_plan_error This feature is not implemented: Unsupported logical plan: Dml(Delete)
48+
physical_plan_error Error during planning: Table 't1' does not support DELETE operations
4949

5050

5151
# Filtered by existing columns, using qualified and unqualified names
@@ -56,7 +56,7 @@ logical_plan
5656
01)Dml: op=[Delete] table=[t1]
5757
02)--Filter: CAST(t1.a AS Int64) = Int64(1) AND t1.b = CAST(Int64(2) AS Utf8View) AND t1.c > CAST(Int64(3) AS Float64) AND CAST(t1.d AS Int64) != Int64(4)
5858
03)----TableScan: t1
59-
physical_plan_error This feature is not implemented: Unsupported logical plan: Dml(Delete)
59+
physical_plan_error Error during planning: Table 't1' does not support DELETE operations
6060

6161

6262
# Filtered by a mix of columns and literal predicates
@@ -67,7 +67,7 @@ logical_plan
6767
01)Dml: op=[Delete] table=[t1]
6868
02)--Filter: CAST(t1.a AS Int64) = Int64(1) AND Int64(1) = Int64(1) AND Boolean(true)
6969
03)----TableScan: t1
70-
physical_plan_error This feature is not implemented: Unsupported logical plan: Dml(Delete)
70+
physical_plan_error Error during planning: Table 't1' does not support DELETE operations
7171

7272

7373
# Deleting by columns that do not exist returns an error

datafusion/sqllogictest/test_files/update.slt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ logical_plan
3333
01)Dml: op=[Update] table=[t1]
3434
02)--Projection: CAST(Int64(1) AS Int32) AS a, CAST(Int64(2) AS Utf8View) AS b, Float64(3) AS c, CAST(NULL AS Int32) AS d
3535
03)----TableScan: t1
36-
physical_plan_error This feature is not implemented: Unsupported logical plan: Dml(Update)
36+
physical_plan_error Error during planning: Table 't1' does not support UPDATE operations
3737

3838
query TT
3939
explain update t1 set a=c+1, b=a, c=c+1.0, d=b;
@@ -42,7 +42,7 @@ logical_plan
4242
01)Dml: op=[Update] table=[t1]
4343
02)--Projection: CAST(t1.c + CAST(Int64(1) AS Float64) AS Int32) AS a, CAST(t1.a AS Utf8View) AS b, t1.c + Float64(1) AS c, CAST(t1.b AS Int32) AS d
4444
03)----TableScan: t1
45-
physical_plan_error This feature is not implemented: Unsupported logical plan: Dml(Update)
45+
physical_plan_error Error during planning: Table 't1' does not support UPDATE operations
4646

4747
statement ok
4848
create table t2(a int, b varchar, c double, d int);
@@ -73,7 +73,7 @@ logical_plan
7373
04)------Cross Join:
7474
05)--------TableScan: t1
7575
06)--------TableScan: t2
76-
physical_plan_error This feature is not implemented: Unsupported logical plan: Dml(Update)
76+
physical_plan_error Error during planning: Table 't1' does not support UPDATE operations
7777

7878
statement ok
7979
create table t3(a int, b varchar, c double, d int);
@@ -94,4 +94,4 @@ logical_plan
9494
05)--------SubqueryAlias: t
9595
06)----------TableScan: t1
9696
07)--------TableScan: t2
97-
physical_plan_error This feature is not implemented: Unsupported logical plan: Dml(Update)
97+
physical_plan_error Error during planning: Table 't1' does not support UPDATE operations

0 commit comments

Comments
 (0)