@@ -2484,9 +2484,9 @@ mod tests {
2484
2484
// verify that the plan correctly casts u8 to i64
2485
2485
// the cast from u8 to i64 for literal will be simplified, and get lit(int64(5))
2486
2486
// the cast here is implicit so has CastOptions with safe=true
2487
- let expected = r#"BinaryExpr { left: Column { name: "c7", index: 2 }, op: Lt, right: Literal { value: Int64(5), field: Field { name: "lit", data_type: Int64, nullable: false, dict_id: 0, dict_is_ordered: false, metadata: { } } } , fail_on_overflow: false } "# ;
2487
+ let expected = r#"BinaryExpr { left: Column { name: "c7", index: 2 }, op: Lt, right: Literal { value: Int64(5), field: Field { name: "lit", data_type: Int64 } }, fail_on_overflow: false"# ;
2488
2488
2489
- assert ! ( format!( "{exec_plan:?}" ) . contains ( expected) ) ;
2489
+ assert_contains ! ( format!( "{exec_plan:?}" ) , expected) ;
2490
2490
Ok ( ( ) )
2491
2491
}
2492
2492
@@ -2510,9 +2510,7 @@ mod tests {
2510
2510
& session_state,
2511
2511
) ;
2512
2512
2513
- let expected = r#"Ok(PhysicalGroupBy { expr: [(Column { name: "c1", index: 0 }, "c1"), (Column { name: "c2", index: 1 }, "c2"), (Column { name: "c3", index: 2 }, "c3")], null_expr: [(Literal { value: Utf8(NULL), field: Field { name: "lit", data_type: Utf8, nullable: true, dict_id: 0, dict_is_ordered: false, metadata: {} } }, "c1"), (Literal { value: Int64(NULL), field: Field { name: "lit", data_type: Int64, nullable: true, dict_id: 0, dict_is_ordered: false, metadata: {} } }, "c2"), (Literal { value: Int64(NULL), field: Field { name: "lit", data_type: Int64, nullable: true, dict_id: 0, dict_is_ordered: false, metadata: {} } }, "c3")], groups: [[false, false, false], [true, false, false], [false, true, false], [false, false, true], [true, true, false], [true, false, true], [false, true, true], [true, true, true]] })"# ;
2514
-
2515
- assert_eq ! ( format!( "{cube:?}" ) , expected) ;
2513
+ insta:: assert_snapshot!( format!( "{cube:?}" ) , @r#"Ok(PhysicalGroupBy { expr: [(Column { name: "c1", index: 0 }, "c1"), (Column { name: "c2", index: 1 }, "c2"), (Column { name: "c3", index: 2 }, "c3")], null_expr: [(Literal { value: Utf8(NULL), field: Field { name: "lit", data_type: Utf8, nullable: true } }, "c1"), (Literal { value: Int64(NULL), field: Field { name: "lit", data_type: Int64, nullable: true } }, "c2"), (Literal { value: Int64(NULL), field: Field { name: "lit", data_type: Int64, nullable: true } }, "c3")], groups: [[false, false, false], [true, false, false], [false, true, false], [false, false, true], [true, true, false], [true, false, true], [false, true, true], [true, true, true]] })"# ) ;
2516
2514
2517
2515
Ok ( ( ) )
2518
2516
}
@@ -2537,9 +2535,7 @@ mod tests {
2537
2535
& session_state,
2538
2536
) ;
2539
2537
2540
- let expected = r#"Ok(PhysicalGroupBy { expr: [(Column { name: "c1", index: 0 }, "c1"), (Column { name: "c2", index: 1 }, "c2"), (Column { name: "c3", index: 2 }, "c3")], null_expr: [(Literal { value: Utf8(NULL), field: Field { name: "lit", data_type: Utf8, nullable: true, dict_id: 0, dict_is_ordered: false, metadata: {} } }, "c1"), (Literal { value: Int64(NULL), field: Field { name: "lit", data_type: Int64, nullable: true, dict_id: 0, dict_is_ordered: false, metadata: {} } }, "c2"), (Literal { value: Int64(NULL), field: Field { name: "lit", data_type: Int64, nullable: true, dict_id: 0, dict_is_ordered: false, metadata: {} } }, "c3")], groups: [[true, true, true], [false, true, true], [false, false, true], [false, false, false]] })"# ;
2541
-
2542
- assert_eq ! ( format!( "{rollup:?}" ) , expected) ;
2538
+ insta:: assert_snapshot!( format!( "{rollup:?}" ) , @r#"Ok(PhysicalGroupBy { expr: [(Column { name: "c1", index: 0 }, "c1"), (Column { name: "c2", index: 1 }, "c2"), (Column { name: "c3", index: 2 }, "c3")], null_expr: [(Literal { value: Utf8(NULL), field: Field { name: "lit", data_type: Utf8, nullable: true } }, "c1"), (Literal { value: Int64(NULL), field: Field { name: "lit", data_type: Int64, nullable: true } }, "c2"), (Literal { value: Int64(NULL), field: Field { name: "lit", data_type: Int64, nullable: true } }, "c3")], groups: [[true, true, true], [false, true, true], [false, false, true], [false, false, false]] })"# ) ;
2543
2539
2544
2540
Ok ( ( ) )
2545
2541
}
@@ -2677,35 +2673,13 @@ mod tests {
2677
2673
let logical_plan = LogicalPlan :: Extension ( Extension {
2678
2674
node : Arc :: new ( NoOpExtensionNode :: default ( ) ) ,
2679
2675
} ) ;
2680
- let plan = planner
2676
+ let e = planner
2681
2677
. create_physical_plan ( & logical_plan, & session_state)
2682
- . await ;
2678
+ . await
2679
+ . expect_err ( "planning error" )
2680
+ . strip_backtrace ( ) ;
2683
2681
2684
- let expected_error: & str = "Error during planning: \
2685
- Extension planner for NoOp created an ExecutionPlan with mismatched schema. \
2686
- LogicalPlan schema: \
2687
- DFSchema { inner: Schema { fields: \
2688
- [Field { name: \" a\" , \
2689
- data_type: Int32, \
2690
- nullable: false, \
2691
- dict_id: 0, \
2692
- dict_is_ordered: false, metadata: {} }], \
2693
- metadata: {} }, field_qualifiers: [None], \
2694
- functional_dependencies: FunctionalDependencies { deps: [] } }, \
2695
- ExecutionPlan schema: Schema { fields: \
2696
- [Field { name: \" b\" , \
2697
- data_type: Int32, \
2698
- nullable: false, \
2699
- dict_id: 0, \
2700
- dict_is_ordered: false, metadata: {} }], \
2701
- metadata: {} }";
2702
- match plan {
2703
- Ok ( _) => panic ! ( "Expected planning failure" ) ,
2704
- Err ( e) => assert ! (
2705
- e. to_string( ) . contains( expected_error) ,
2706
- "Error '{e}' did not contain expected error '{expected_error}'"
2707
- ) ,
2708
- }
2682
+ insta:: assert_snapshot!( e, @r#"Error during planning: Extension planner for NoOp created an ExecutionPlan with mismatched schema. LogicalPlan schema: DFSchema { inner: Schema { fields: [Field { name: "a", data_type: Int32 }], metadata: {} }, field_qualifiers: [None], functional_dependencies: FunctionalDependencies { deps: [] } }, ExecutionPlan schema: Schema { fields: [Field { name: "b", data_type: Int32 }], metadata: {} }"# ) ;
2709
2683
}
2710
2684
2711
2685
#[ tokio:: test]
@@ -2721,10 +2695,9 @@ mod tests {
2721
2695
let execution_plan = plan ( & logical_plan) . await ?;
2722
2696
// verify that the plan correctly adds cast from Int64(1) to Utf8, and the const will be evaluated.
2723
2697
2724
- let expected = "expr: [ProjectionExpr { expr: BinaryExpr { left: BinaryExpr { left: Column { name: \ " c1\ " , index: 0 }, op: Eq, right: Literal { value: Utf8(\" a \ " ), field: Field { name: \ " lit\ " , data_type: Utf8, nullable: false, dict_id: 0, dict_is_ordered: false, metadata: { } } } , fail_on_overflow: false }, op: Or, right: BinaryExpr { left: Column { name: \" c1 \" , index: 0 }, op: Eq, right: Literal { value: Utf8( \" 1 \" ), field: Field { name: \" lit \" , data_type: Utf8, nullable: false, dict_id: 0, dict_is_ordered: false, metadata: {} } }, fail_on_overflow: false }, fail_on_overflow: false }" ;
2698
+ let expected = r# "expr: [ProjectionExpr { expr: BinaryExpr { left: BinaryExpr { left: Column { name: "c1", index: 0 }, op: Eq, right: Literal { value: Utf8("a "), field: Field { name: "lit", data_type: Utf8 } }, fail_on_overflow: false"# ;
2725
2699
2726
- let actual = format ! ( "{execution_plan:?}" ) ;
2727
- assert ! ( actual. contains( expected) , "{}" , actual) ;
2700
+ assert_contains ! ( format!( "{execution_plan:?}" ) , expected) ;
2728
2701
2729
2702
Ok ( ( ) )
2730
2703
}
@@ -2744,7 +2717,7 @@ mod tests {
2744
2717
2745
2718
assert_contains ! (
2746
2719
& e,
2747
- r#"Error during planning: Can not find compatible types to compare Boolean with [Struct(foo Boolean), Utf8]"#
2720
+ r#"Error during planning: Can not find compatible types to compare Boolean with [Struct(" foo": Boolean), Utf8]"#
2748
2721
) ;
2749
2722
2750
2723
Ok ( ( ) )
0 commit comments