@@ -41,8 +41,6 @@ use crate::coalesce_partitions::CoalescePartitionsExec;
41
41
use crate :: display:: DisplayableExecutionPlan ;
42
42
use crate :: metrics:: MetricsSet ;
43
43
use crate :: projection:: ProjectionExec ;
44
- use crate :: repartition:: RepartitionExec ;
45
- use crate :: sorts:: sort_preserving_merge:: SortPreservingMergeExec ;
46
44
use crate :: stream:: RecordBatchStreamAdapter ;
47
45
48
46
use arrow:: array:: { Array , RecordBatch } ;
@@ -559,16 +557,6 @@ pub trait ExecutionPlan: Debug + DisplayAs + Send + Sync {
559
557
child_pushdown_result,
560
558
) )
561
559
}
562
-
563
- /// Returns a version of this plan that cooperates with the runtime via
564
- /// built‐in yielding. If such a version doesn't exist, returns `None`.
565
- /// You do not need to do provide such a version of a custom operator,
566
- /// but DataFusion will utilize it while optimizing the plan if it exists.
567
- fn with_cooperative_yields ( self : Arc < Self > ) -> Option < Arc < dyn ExecutionPlan > > {
568
- // Conservative default implementation assumes that a leaf does not
569
- // cooperate with yielding.
570
- None
571
- }
572
560
}
573
561
574
562
/// [`ExecutionPlan`] Invariant Level
@@ -743,6 +731,26 @@ pub enum EmissionType {
743
731
Both ,
744
732
}
745
733
734
+ #[ derive( Debug , Clone , Copy , PartialEq , Eq ) ]
735
+ pub enum SchedulingType {
736
+ /// The stream generated by [`execute`](ExecutionPlan::execute) does not participate in cooperative scheduling
737
+ Blocking ,
738
+ /// The stream generated by [`execute`](ExecutionPlan::execute) actively participates in cooperative scheduling
739
+ /// by consuming task budget
740
+ Cooperative ,
741
+ }
742
+
743
+ #[ derive( Debug , Clone , Copy , PartialEq , Eq ) ]
744
+ pub enum EvaluationType {
745
+ /// The stream generated by [`execute`](ExecutionPlan::execute) only generates `RecordBatch`
746
+ /// instances when it is demanded by invoking `Stream::poll_next`.
747
+ Lazy ,
748
+ /// The stream generated by [`execute`](ExecutionPlan::execute) eagerly generates `RecordBatch`
749
+ /// in one or more spawned Tokio tasks. Eager evaluation is only started the first time
750
+ /// `Stream::poll_next` is called.
751
+ Eager ,
752
+ }
753
+
746
754
/// Utility to determine an operator's boundedness based on its children's boundedness.
747
755
///
748
756
/// Assumes boundedness can be inferred from child operators:
@@ -831,6 +839,8 @@ pub struct PlanProperties {
831
839
pub emission_type : EmissionType ,
832
840
/// See [ExecutionPlanProperties::boundedness]
833
841
pub boundedness : Boundedness ,
842
+ pub evaluation_type : EvaluationType ,
843
+ pub scheduling_type : SchedulingType ,
834
844
/// See [ExecutionPlanProperties::output_ordering]
835
845
output_ordering : Option < LexOrdering > ,
836
846
}
@@ -850,6 +860,8 @@ impl PlanProperties {
850
860
partitioning,
851
861
emission_type,
852
862
boundedness,
863
+ evaluation_type : EvaluationType :: Lazy ,
864
+ scheduling_type : SchedulingType :: Blocking ,
853
865
output_ordering,
854
866
}
855
867
}
@@ -881,6 +893,16 @@ impl PlanProperties {
881
893
self
882
894
}
883
895
896
+ pub fn with_scheduling_type ( mut self , scheduling_type : SchedulingType ) -> Self {
897
+ self . scheduling_type = scheduling_type;
898
+ self
899
+ }
900
+
901
+ pub fn with_evaluation_type ( mut self , drive_type : EvaluationType ) -> Self {
902
+ self . evaluation_type = drive_type;
903
+ self
904
+ }
905
+
884
906
/// Overwrite constraints with its new value.
885
907
pub fn with_constraints ( mut self , constraints : Constraints ) -> Self {
886
908
self . eq_properties = self . eq_properties . with_constraints ( constraints) ;
@@ -912,25 +934,7 @@ impl PlanProperties {
912
934
/// 2. CoalescePartitionsExec for collapsing all of the partitions into one without ordering guarantee
913
935
/// 3. SortPreservingMergeExec for collapsing all of the sorted partitions into one with ordering guarantee
914
936
pub fn need_data_exchange ( plan : Arc < dyn ExecutionPlan > ) -> bool {
915
- if let Some ( repartition) = plan. as_any ( ) . downcast_ref :: < RepartitionExec > ( ) {
916
- !matches ! (
917
- repartition. properties( ) . output_partitioning( ) ,
918
- Partitioning :: RoundRobinBatch ( _)
919
- )
920
- } else if let Some ( coalesce) = plan. as_any ( ) . downcast_ref :: < CoalescePartitionsExec > ( )
921
- {
922
- coalesce. input ( ) . output_partitioning ( ) . partition_count ( ) > 1
923
- } else if let Some ( sort_preserving_merge) =
924
- plan. as_any ( ) . downcast_ref :: < SortPreservingMergeExec > ( )
925
- {
926
- sort_preserving_merge
927
- . input ( )
928
- . output_partitioning ( )
929
- . partition_count ( )
930
- > 1
931
- } else {
932
- false
933
- }
937
+ plan. properties ( ) . evaluation_type == EvaluationType :: Lazy
934
938
}
935
939
936
940
/// Returns a copy of this plan if we change any child according to the pointer comparison.
0 commit comments