1919//! It will do in-memory sorting if it has enough memory budget
2020//! but spills to disk if needed.
2121
22- use std:: any:: Any ;
23- use std:: fmt;
24- use std:: fmt:: { Debug , Formatter } ;
25- use std:: sync:: Arc ;
26-
2722use crate :: common:: spawn_buffered;
2823use crate :: execution_plan:: { Boundedness , CardinalityEffect , EmissionType } ;
2924use crate :: expressions:: PhysicalSortExpr ;
@@ -43,6 +38,10 @@ use crate::{
4338 ExecutionPlanProperties , Partitioning , PlanProperties , SendableRecordBatchStream ,
4439 Statistics ,
4540} ;
41+ use std:: any:: Any ;
42+ use std:: fmt;
43+ use std:: fmt:: { Debug , Formatter } ;
44+ use std:: sync:: Arc ;
4645
4746use arrow:: array:: { Array , RecordBatch , RecordBatchOptions , StringViewArray } ;
4847use arrow:: compute:: { concat_batches, lexsort_to_indices, take_arrays} ;
@@ -1107,10 +1106,9 @@ impl ExecutionPlan for SortExec {
11071106 . equivalence_properties ( )
11081107 . ordering_satisfy_requirement ( requirement) ;
11091108
1110- let mut input = PollBudget :: from ( context. as_ref ( ) ) . wrap_stream ( input) ;
1111-
11121109 match ( sort_satisfied, self . fetch . as_ref ( ) ) {
11131110 ( true , Some ( fetch) ) => Ok ( Box :: pin ( LimitStream :: new (
1111+ // limit is not a pipeline breaking stream, so poll budget is not required
11141112 input,
11151113 0 ,
11161114 Some ( * fetch) ,
@@ -1128,6 +1126,7 @@ impl ExecutionPlan for SortExec {
11281126 context. runtime_env ( ) ,
11291127 & self . metrics_set ,
11301128 ) ?;
1129+ let mut input = PollBudget :: from ( context. as_ref ( ) ) . wrap_stream ( input) ;
11311130 Ok ( Box :: pin ( RecordBatchStreamAdapter :: new (
11321131 self . schema ( ) ,
11331132 futures:: stream:: once ( async move {
@@ -1154,6 +1153,7 @@ impl ExecutionPlan for SortExec {
11541153 & self . metrics_set ,
11551154 context. runtime_env ( ) ,
11561155 ) ?;
1156+ let mut input = PollBudget :: from ( context. as_ref ( ) ) . wrap_stream ( input) ;
11571157 Ok ( Box :: pin ( RecordBatchStreamAdapter :: new (
11581158 self . schema ( ) ,
11591159 futures:: stream:: once ( async move {
0 commit comments