@@ -1696,9 +1696,11 @@ mod tests {
16961696 async fn plan ( logical_plan : & LogicalPlan ) -> Result < Arc < dyn ExecutionPlan > > {
16971697 let mut session_state = make_session_state ( ) ;
16981698 session_state. config . target_partitions = 4 ;
1699+ // optimize the logical plan
1700+ let logical_plan = session_state. optimize ( logical_plan) ?;
16991701 let planner = DefaultPhysicalPlanner :: default ( ) ;
17001702 planner
1701- . create_physical_plan ( logical_plan, & session_state)
1703+ . create_physical_plan ( & logical_plan, & session_state)
17021704 . await
17031705 }
17041706
@@ -1714,12 +1716,12 @@ mod tests {
17141716 . limit ( 3 , Some ( 10 ) ) ?
17151717 . build ( ) ?;
17161718
1717- let plan = plan ( & logical_plan) . await ?;
1719+ let exec_plan = plan ( & logical_plan) . await ?;
17181720
17191721 // verify that the plan correctly casts u8 to i64
17201722 // the cast here is implicit so has CastOptions with safe=true
1721- let expected = "BinaryExpr { left: Column { name: \" c7\" , index: 6 }, op: Lt, right: TryCastExpr { expr: Literal { value: UInt8 (5) }, cast_type: Int64 } }" ;
1722- assert ! ( format!( "{:?}" , plan ) . contains( expected) ) ;
1723+ let expected = "BinaryExpr { left: Column { name: \" c7\" , index: 2 }, op: Lt, right: Literal { value: Int64 (5) } }" ;
1724+ assert ! ( format!( "{:?}" , exec_plan ) . contains( expected) ) ;
17231725
17241726 Ok ( ( ) )
17251727 }
@@ -1821,8 +1823,7 @@ mod tests {
18211823 async fn test_with_zero_offset_plan ( ) -> Result < ( ) > {
18221824 let logical_plan = test_csv_scan ( ) . await ?. limit ( 0 , None ) ?. build ( ) ?;
18231825 let plan = plan ( & logical_plan) . await ?;
1824- assert ! ( format!( "{:?}" , plan) . contains( "GlobalLimitExec" ) ) ;
1825- assert ! ( format!( "{:?}" , plan) . contains( "skip: 0" ) ) ;
1826+ assert ! ( format!( "{:?}" , plan) . contains( "limit: None" ) ) ;
18261827 Ok ( ( ) )
18271828 }
18281829
@@ -1952,8 +1953,8 @@ mod tests {
19521953 . project ( vec ! [ col( "c1" ) . in_list( list, false ) ] ) ?
19531954 . build ( ) ?;
19541955 let execution_plan = plan ( & logical_plan) . await ?;
1955- // verify that the plan correctly adds cast from Int64(1) to Utf8
1956- let expected = "expr: [(InListExpr { expr: Column { name: \" c1\" , index: 0 }, list: [Literal { value: Utf8(\" a\" ) }, TryCastExpr { expr: Literal { value: Int64(1) }, cast_type: Utf8 }], negated: false, set: None }" ;
1956+ // verify that the plan correctly adds cast from Int64(1) to Utf8, and the const will be evaluated.
1957+ let expected = "expr: [(InListExpr { expr: Column { name: \" c1\" , index: 0 }, list: [Literal { value: Utf8(\" a\" ) }, Literal { value: Utf8( \" 1 \" ) }], negated: false, set: None }" ;
19571958 assert ! ( format!( "{:?}" , execution_plan) . contains( expected) ) ;
19581959
19591960 // expression: "a in (struct::null, 'a')"
@@ -1965,10 +1966,9 @@ mod tests {
19651966 . filter ( col ( "c12" ) . lt ( lit ( 0.05 ) ) ) ?
19661967 . project ( vec ! [ col( "c12" ) . lt_eq( lit( 0.025 ) ) . in_list( list, false ) ] ) ?
19671968 . build ( ) ?;
1968- let execution_plan = plan ( & logical_plan) . await ;
1969+ let e = plan ( & logical_plan) . await . unwrap_err ( ) . to_string ( ) ;
19691970
1970- let e = execution_plan. unwrap_err ( ) . to_string ( ) ;
1971- assert_contains ! ( & e, "Can not find compatible types to compare Boolean with [Struct([Field { name: \" foo\" , data_type: Boolean, nullable: false, dict_id: 0, dict_is_ordered: false, metadata: None }]), Utf8]" ) ;
1971+ assert_contains ! ( & e, "The data type inlist should be same, the value type is Boolean, one of list expr type is Struct([Field { name: \" foo\" , data_type: Boolean, nullable: false, dict_id: 0, dict_is_ordered: false, metadata: None }])" ) ;
19721972
19731973 Ok ( ( ) )
19741974 }
@@ -1996,7 +1996,10 @@ mod tests {
19961996 . project ( vec ! [ col( "c1" ) . in_list( list, false ) ] ) ?
19971997 . build ( ) ?;
19981998 let execution_plan = plan ( & logical_plan) . await ?;
1999- let expected = "expr: [(InListExpr { expr: Column { name: \" c1\" , index: 0 }, list: [Literal { value: Utf8(\" a\" ) }, TryCastExpr { expr: Literal { value: Int64(1) }, cast_type: Utf8 }, TryCastExpr { expr: Literal { value: Int64(2) }, cast_type: Utf8 }, TryCastExpr { expr: Literal { value: Int64(3) }, cast_type: Utf8 }, TryCastExpr { expr: Literal { value: Int64(4) }, cast_type: Utf8 }, TryCastExpr { expr: Literal { value: Int64(5) }, cast_type: Utf8 }, TryCastExpr { expr: Literal { value: Int64(6) }, cast_type: Utf8 }, TryCastExpr { expr: Literal { value: Int64(7) }, cast_type: Utf8 }, TryCastExpr { expr: Literal { value: Int64(8) }, cast_type: Utf8 }, TryCastExpr { expr: Literal { value: Int64(9) }, cast_type: Utf8 }, TryCastExpr { expr: Literal { value: Int64(10) }, cast_type: Utf8 }, TryCastExpr { expr: Literal { value: Int64(11) }, cast_type: Utf8 }, TryCastExpr { expr: Literal { value: Int64(12) }, cast_type: Utf8 }, TryCastExpr { expr: Literal { value: Int64(13) }, cast_type: Utf8 }, TryCastExpr { expr: Literal { value: Int64(14) }, cast_type: Utf8 }, TryCastExpr { expr: Literal { value: Int64(15) }, cast_type: Utf8 }, TryCastExpr { expr: Literal { value: Int64(16) }, cast_type: Utf8 }, TryCastExpr { expr: Literal { value: Int64(17) }, cast_type: Utf8 }, TryCastExpr { expr: Literal { value: Int64(18) }, cast_type: Utf8 }, TryCastExpr { expr: Literal { value: Int64(19) }, cast_type: Utf8 }, TryCastExpr { expr: Literal { value: Int64(20) }, cast_type: Utf8 }, TryCastExpr { expr: Literal { value: Int64(21) }, cast_type: Utf8 }, TryCastExpr { expr: Literal { value: Int64(22) }, cast_type: Utf8 }, TryCastExpr { expr: Literal { value: Int64(23) }, cast_type: Utf8 }, TryCastExpr { expr: Literal { value: Int64(24) }, cast_type: Utf8 }, TryCastExpr { expr: Literal { value: Int64(25) }, cast_type: Utf8 }, TryCastExpr { expr: Literal { value: Int64(26) }, cast_type: Utf8 }, TryCastExpr { expr: Literal { value: Int64(27) }, cast_type: Utf8 }, TryCastExpr { expr: Literal { value: Int64(28) }, cast_type: Utf8 }, TryCastExpr { expr: Literal { value: Int64(29) }, cast_type: Utf8 }, TryCastExpr { expr: Literal { value: Int64(30) }, cast_type: Utf8 }], negated: false, set: Some(InSet { set: " ;
1999+ let expected = "expr: [(InListExpr { expr: Column { name: \" c1\" , index: 0 }, list: [Literal { value: Utf8(\" a\" ) }, Literal { value: Utf8(\" 1\" ) }, Literal { value: Utf8(\" 2\" ) }," ;
2000+ assert ! ( format!( "{:?}" , execution_plan) . contains( expected) ) ;
2001+ let expected =
2002+ "Literal { value: Utf8(\" 30\" ) }], negated: false, set: Some(InSet { set: " ;
20002003 assert ! ( format!( "{:?}" , execution_plan) . contains( expected) ) ;
20012004 Ok ( ( ) )
20022005 }
@@ -2015,7 +2018,10 @@ mod tests {
20152018 . project ( vec ! [ col( "c1" ) . in_list( list, false ) ] ) ?
20162019 . build ( ) ?;
20172020 let execution_plan = plan ( & logical_plan) . await ?;
2018- let expected = "expr: [(InListExpr { expr: Column { name: \" c1\" , index: 0 }, list: [TryCastExpr { expr: Literal { value: Int64(NULL) }, cast_type: Utf8 }, TryCastExpr { expr: Literal { value: Int64(1) }, cast_type: Utf8 }, TryCastExpr { expr: Literal { value: Int64(2) }, cast_type: Utf8 }, TryCastExpr { expr: Literal { value: Int64(3) }, cast_type: Utf8 }, TryCastExpr { expr: Literal { value: Int64(4) }, cast_type: Utf8 }, TryCastExpr { expr: Literal { value: Int64(5) }, cast_type: Utf8 }, TryCastExpr { expr: Literal { value: Int64(6) }, cast_type: Utf8 }, TryCastExpr { expr: Literal { value: Int64(7) }, cast_type: Utf8 }, TryCastExpr { expr: Literal { value: Int64(8) }, cast_type: Utf8 }, TryCastExpr { expr: Literal { value: Int64(9) }, cast_type: Utf8 }, TryCastExpr { expr: Literal { value: Int64(10) }, cast_type: Utf8 }, TryCastExpr { expr: Literal { value: Int64(11) }, cast_type: Utf8 }, TryCastExpr { expr: Literal { value: Int64(12) }, cast_type: Utf8 }, TryCastExpr { expr: Literal { value: Int64(13) }, cast_type: Utf8 }, TryCastExpr { expr: Literal { value: Int64(14) }, cast_type: Utf8 }, TryCastExpr { expr: Literal { value: Int64(15) }, cast_type: Utf8 }, TryCastExpr { expr: Literal { value: Int64(16) }, cast_type: Utf8 }, TryCastExpr { expr: Literal { value: Int64(17) }, cast_type: Utf8 }, TryCastExpr { expr: Literal { value: Int64(18) }, cast_type: Utf8 }, TryCastExpr { expr: Literal { value: Int64(19) }, cast_type: Utf8 }, TryCastExpr { expr: Literal { value: Int64(20) }, cast_type: Utf8 }, TryCastExpr { expr: Literal { value: Int64(21) }, cast_type: Utf8 }, TryCastExpr { expr: Literal { value: Int64(22) }, cast_type: Utf8 }, TryCastExpr { expr: Literal { value: Int64(23) }, cast_type: Utf8 }, TryCastExpr { expr: Literal { value: Int64(24) }, cast_type: Utf8 }, TryCastExpr { expr: Literal { value: Int64(25) }, cast_type: Utf8 }, TryCastExpr { expr: Literal { value: Int64(26) }, cast_type: Utf8 }, TryCastExpr { expr: Literal { value: Int64(27) }, cast_type: Utf8 }, TryCastExpr { expr: Literal { value: Int64(28) }, cast_type: Utf8 }, TryCastExpr { expr: Literal { value: Int64(29) }, cast_type: Utf8 }, TryCastExpr { expr: Literal { value: Int64(30) }, cast_type: Utf8 }], negated: false, set: Some(InSet {" ;
2021+ let expected = "expr: [(InListExpr { expr: Column { name: \" c1\" , index: 0 }, list: [Literal { value: Utf8(NULL) }, Literal { value: Utf8(\" 1\" ) }, Literal { value: Utf8(\" 2\" ) }" ;
2022+ assert ! ( format!( "{:?}" , execution_plan) . contains( expected) ) ;
2023+ let expected =
2024+ "Literal { value: Utf8(\" 30\" ) }], negated: false, set: Some(InSet" ;
20192025 assert ! ( format!( "{:?}" , execution_plan) . contains( expected) ) ;
20202026 Ok ( ( ) )
20212027 }
0 commit comments