@@ -2492,7 +2492,6 @@ mod tests {
24922492
24932493 use super :: * ;
24942494 use crate :: coalesce_partitions:: CoalescePartitionsExec ;
2495- use crate :: collect;
24962495 use crate :: empty:: EmptyExec ;
24972496 use crate :: execution_plan:: Boundedness ;
24982497 use crate :: expressions:: col;
@@ -2502,6 +2501,7 @@ mod tests {
25022501 use crate :: test:: TestMemoryExec ;
25032502 use crate :: test:: exec:: { BlockingExec , assert_strong_count_converges_to_zero} ;
25042503 use crate :: test:: { assert_is_pending, make_partition} ;
2504+ use crate :: { collect, collect_partitioned} ;
25052505
25062506 use arrow:: array:: * ;
25072507 use arrow:: compute:: SortOptions ;
@@ -2610,15 +2610,14 @@ mod tests {
26102610
26112611 #[ tokio:: test( flavor = "multi_thread" , worker_threads = 2 ) ]
26122612 async fn sort_execution_initializes_and_resets_concurrency ( ) -> Result < ( ) > {
2613- let batch = RecordBatch :: try_from_iter ( [ (
2614- "a" ,
2615- Arc :: new ( Int32Array :: from ( vec ! [ 2 , 1 ] ) ) as ArrayRef ,
2616- ) ] ) ?;
2617- let input = TestMemoryExec :: try_new_exec (
2618- & [ vec ! [ batch. clone( ) ; 2 ] , vec ! [ batch. clone( ) ; 2 ] ] ,
2619- batch. schema ( ) ,
2620- None ,
2613+ let batch = record_batch ! (
2614+ ( "a" , Int32 , [ 2 , 1 , 2 , 1 ] ) ,
2615+ ( "payload" , Utf8 , [ "b" , "a" , "d" , "c" ] )
26212616 ) ?;
2617+ // Distinct payloads make equal-key ordering across runs observable.
2618+ let runs = vec ! [ batch. slice( 0 , 2 ) , batch. slice( 2 , 2 ) ] ;
2619+ let input =
2620+ TestMemoryExec :: try_new_exec ( & [ runs. clone ( ) , runs] , batch. schema ( ) , None ) ?;
26222621 let sort = SortExec :: new (
26232622 [ PhysicalSortExpr :: new_default ( col ( "a" , & batch. schema ( ) ) ?) ] . into ( ) ,
26242623 input,
@@ -2629,7 +2628,16 @@ mod tests {
26292628 ) ) ;
26302629
26312630 // Execution must initialize the cell owned by the plan, not a private sorter cell.
2632- collect ( Arc :: new ( sort. clone ( ) ) , Arc :: clone ( & context) ) . await ?;
2631+ let output =
2632+ collect_partitioned ( Arc :: new ( sort. clone ( ) ) , Arc :: clone ( & context) ) . await ?;
2633+ let expected = record_batch ! (
2634+ ( "a" , Int32 , [ 1 , 1 , 2 , 2 ] ) ,
2635+ ( "payload" , Utf8 , [ "a" , "c" , "b" , "d" ] )
2636+ ) ?;
2637+ assert_eq ! ( output. len( ) , 2 ) ;
2638+ for partition in output {
2639+ assert_eq ! ( concat_batches( & batch. schema( ) , & partition) ?, expected) ;
2640+ }
26332641 assert ! ( sort. sort_concurrency. get( ) . is_some( ) ) ;
26342642 let reset = Arc :: new ( sort. clone ( ) ) . reset_state ( ) ?;
26352643 assert ! (
0 commit comments