@@ -2484,9 +2484,9 @@ mod tests {
24842484 // verify that the plan correctly casts u8 to i64
24852485 // the cast from u8 to i64 for literal will be simplified, and get lit(int64(5))
24862486 // 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"# ;
24882488
2489- assert ! ( format!( "{exec_plan:?}" ) . contains ( expected) ) ;
2489+ assert_contains ! ( format!( "{exec_plan:?}" ) , expected) ;
24902490 Ok ( ( ) )
24912491 }
24922492
@@ -2510,9 +2510,7 @@ mod tests {
25102510 & session_state,
25112511 ) ;
25122512
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]] })"# ) ;
25162514
25172515 Ok ( ( ) )
25182516 }
@@ -2537,9 +2535,7 @@ mod tests {
25372535 & session_state,
25382536 ) ;
25392537
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]] })"# ) ;
25432539
25442540 Ok ( ( ) )
25452541 }
@@ -2677,35 +2673,13 @@ mod tests {
26772673 let logical_plan = LogicalPlan :: Extension ( Extension {
26782674 node : Arc :: new ( NoOpExtensionNode :: default ( ) ) ,
26792675 } ) ;
2680- let plan = planner
2676+ let e = planner
26812677 . create_physical_plan ( & logical_plan, & session_state)
2682- . await ;
2678+ . await
2679+ . expect_err ( "planning error" )
2680+ . strip_backtrace ( ) ;
26832681
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: {} }"# ) ;
27092683 }
27102684
27112685 #[ tokio:: test]
@@ -2721,10 +2695,9 @@ mod tests {
27212695 let execution_plan = plan ( & logical_plan) . await ?;
27222696 // verify that the plan correctly adds cast from Int64(1) to Utf8, and the const will be evaluated.
27232697
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"# ;
27252699
2726- let actual = format ! ( "{execution_plan:?}" ) ;
2727- assert ! ( actual. contains( expected) , "{}" , actual) ;
2700+ assert_contains ! ( format!( "{execution_plan:?}" ) , expected) ;
27282701
27292702 Ok ( ( ) )
27302703 }
@@ -2744,7 +2717,7 @@ mod tests {
27442717
27452718 assert_contains ! (
27462719 & 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]"#
27482721 ) ;
27492722
27502723 Ok ( ( ) )
0 commit comments