@@ -341,30 +341,29 @@ impl Aggregating {
341341 // Check the reservation before taking completed groups, as the partial
342342 // stream does, so spilling is unchanged. Without spilling, the refusal
343343 // is returned below only if no group is complete.
344- let oom = match (
345- reservation. try_resize ( self . reservation_size ( ) ) ,
346- self . spill_context . as_mut ( ) ,
347- ) {
348- ( Ok ( ( ) ) , _) => None ,
349- ( Err ( oom @ DataFusionError :: ResourcesExhausted ( _) ) , None ) => Some ( oom) ,
350- (
351- Err ( oom @ DataFusionError :: ResourcesExhausted ( _) ) ,
352- Some ( spill_context) ,
353- ) => {
354- if self . table . is_empty ( ) {
355- return Err ( oom) ;
344+ let oom = match reservation. try_resize ( self . reservation_size ( ) ) {
345+ Ok ( ( ) ) => None ,
346+ Err ( oom @ DataFusionError :: ResourcesExhausted ( _) ) => {
347+ match self . spill_context . as_mut ( ) {
348+ None => Some ( oom) ,
349+ Some ( spill_context) => {
350+ if self . table . is_empty ( ) {
351+ return Err ( oom) ;
352+ }
353+ spill_context
354+ . sort_and_spill ( self . table . take_state_batch ( ) ?) ?;
355+ reservation. try_resize ( self . table . memory_size ( ) ) . map_err (
356+ |e| {
357+ e. context (
358+ "Decreasing allocation after spilling should succeed" ,
359+ )
360+ } ,
361+ ) ?;
362+ continue ;
363+ }
356364 }
357- spill_context. sort_and_spill ( self . table . take_state_batch ( ) ?) ?;
358- reservation
359- . try_resize ( self . table . memory_size ( ) )
360- . map_err ( |e| {
361- e. context (
362- "Decreasing allocation after spilling should succeed" ,
363- )
364- } ) ?;
365- continue ;
366365 }
367- ( Err ( e) , _ ) => return Err ( e) ,
366+ Err ( e) => return Err ( e) ,
368367 } ;
369368
370369 if self . spill_context . as_ref ( ) . is_some_and ( |s| s. has_spills ( ) ) {
0 commit comments