@@ -4270,35 +4270,10 @@ mod tests {
42704270 assert ! ( !PhysicalPlanner :: keeps_source_order( & scan( 2 ) ) ) ;
42714271 }
42724272
4273- #[ test]
4274- fn declared_order_reaches_an_empty_bucket ( ) {
4275- // A bucket with no file is planned as an `EmptyExec`. A window over it checks its input's
4276- // order before polling it, so the order Spark reports has to be declared there as well.
4277- let schema = Arc :: new ( Schema :: new ( vec ! [ Field :: new(
4278- "col_0" ,
4279- DataType :: Int32 ,
4280- true ,
4281- ) ] ) ) ;
4282- let empty: Arc < dyn ExecutionPlan > =
4283- Arc :: new ( datafusion:: physical_plan:: empty:: EmptyExec :: new ( schema) ) ;
4284- let input = PhysicalPlanner :: default ( )
4285- . with_declared_order ( empty, & [ create_sort_order ( 0 , 3 , false , true ) ] )
4286- . unwrap ( ) ;
4287- assert_eq ! ( "SortedInputExec" , input. name( ) ) ;
4288- let partition_by: Vec < Arc < dyn PhysicalExpr > > = vec ! [ Arc :: new( Column :: new( "col_0" , 0 ) ) ] ;
4289- assert_eq ! (
4290- 1 ,
4291- get_ordered_partition_by_indices( & partition_by, & input)
4292- . unwrap( )
4293- . len( )
4294- ) ;
4295- }
4296-
42974273 #[ test]
42984274 fn declared_order_extends_an_order_the_input_declares ( ) {
4299- // Two aliases of one column share an order, so a window over the window for one alias can
4300- // need the other's order while its input declares only the first. That order is declared
4301- // next to the input's, unless an operator in between may have moved rows.
4275+ // An order is declared over an empty bucket, and next to the order the input declares,
4276+ // unless an operator in between may have moved rows.
43024277 let schema = Arc :: new ( Schema :: new ( vec ! [
43034278 Field :: new( "col_0" , DataType :: Int32 , true ) ,
43044279 Field :: new( "col_1" , DataType :: Int32 , true ) ,
@@ -4315,6 +4290,7 @@ mod tests {
43154290 let empty: Arc < dyn ExecutionPlan > =
43164291 Arc :: new ( datafusion:: physical_plan:: empty:: EmptyExec :: new ( schema) ) ;
43174292 let by_col_0 = declare ( & empty, 0 ) ;
4293+ assert_eq ! ( "SortedInputExec" , by_col_0. name( ) ) ;
43184294 assert ! ( Arc :: ptr_eq( & declare( & by_col_0, 0 ) , & by_col_0) ) ;
43194295
43204296 let both = declare ( & by_col_0, 1 ) ;
@@ -4525,8 +4501,8 @@ mod tests {
45254501
45264502 #[ test]
45274503 fn window_declares_input_order_on_a_scan ( ) {
4528- // Both window operators need their partition keys' order declared, and over a `ScanExec`
4529- // only the order Spark sent declares it . `percent_rank` does not run with bounded memory .
4504+ // Both window operators need their partition keys' order, which a `ScanExec` declares
4505+ // only through the order Spark sent. `percent_rank` runs in `WindowAggExec` .
45304506 let partition_by: Vec < Arc < dyn PhysicalExpr > > = vec ! [ Arc :: new( Column :: new( "col_0" , 0 ) ) ] ;
45314507 for ( func, operator) in [
45324508 ( "row_number" , "BoundedWindowAggExec" ) ,
@@ -4544,14 +4520,7 @@ mod tests {
45444520 Arc :: clone ( planned. native_plan . children ( ) [ 0 ] )
45454521 } ;
45464522 let input = window_input ( vec ! [ create_sort_order( 0 , 3 , false , true ) ] ) ;
4547- let sorted = input
4548- . downcast_ref :: < crate :: execution:: operators:: SortedInputExec > ( )
4549- . expect ( "the window's input declares the order Spark sent" ) ;
4550- assert_eq ! ( "ScanExec" , sorted. children( ) [ 0 ] . name( ) ) ;
4551- assert_eq ! (
4552- "col_0@0 ASC" ,
4553- input. properties( ) . output_ordering( ) . unwrap( ) . to_string( )
4554- ) ;
4523+ assert_eq ! ( "SortedInputExec" , input. name( ) ) ;
45554524 let ordered = get_ordered_partition_by_indices ( & partition_by, & input) . unwrap ( ) ;
45564525 assert_eq ! ( 1 , ordered. len( ) , "{func}" ) ;
45574526
0 commit comments