PhysicalOptimizerRule

Trait PhysicalOptimizerRule 

Source
pub trait PhysicalOptimizerRule: Debug {
    // Required methods
    fn optimize(
        &self,
        plan: Arc<dyn ExecutionPlan>,
        config: &ConfigOptions,
    ) -> Result<Arc<dyn ExecutionPlan>>;
    fn name(&self) -> &str;
    fn schema_check(&self) -> bool;
}
Expand description

PhysicalOptimizerRule transforms one [‘ExecutionPlan’] into another which computes the same results, but in a potentially more efficient way.

Use SessionState::add_physical_optimizer_rule to register additional PhysicalOptimizerRules.

Required Methods§

Source

fn optimize( &self, plan: Arc<dyn ExecutionPlan>, config: &ConfigOptions, ) -> Result<Arc<dyn ExecutionPlan>>

Rewrite plan to an optimized form

Source

fn name(&self) -> &str

A human readable name for this optimizer rule

Source

fn schema_check(&self) -> bool

A flag to indicate whether the physical planner should validate that the rule will not change the schema of the plan after the rewriting. Some of the optimization rules might change the nullable properties of the schema and should disable the schema check.

Implementors§

Source§

impl PhysicalOptimizerRule for AggregateStatistics

Source§

impl PhysicalOptimizerRule for CoalesceAsyncExecInput

Source§

impl PhysicalOptimizerRule for CoalesceBatches

Source§

impl PhysicalOptimizerRule for CombinePartialFinalAggregate

Source§

impl PhysicalOptimizerRule for EnforceDistribution

Source§

impl PhysicalOptimizerRule for EnforceSorting

Performs optimizations based upon a series of subrules. Refer to each subrule for detailed descriptions of the optimizations performed: Subrule application is ordering dependent.

Optimizer consists of 5 main parts which work sequentially

  1. ensure_sorting Works down-to-top to be able to remove unnecessary SortExecs, SortPreservingMergeExecs add SortExecs if necessary by a requirement and adjusts window operators.
  2. parallelize_sorts (Optional, depends on the repartition_sorts configuration) Responsible to identify and remove unnecessary partition unifier operators such as SortPreservingMergeExec, CoalescePartitionsExec follows SortExecs does possible simplifications.
  3. replace_with_order_preserving_variants() Replaces with alternative operators, for example can merge a SortExec and a CoalescePartitionsExec into one SortPreservingMergeExec or a SortExec + RepartitionExec combination into an order preserving RepartitionExec
  4. sort_pushdown Works top-down. Responsible to push down sort operators as deep as possible in the plan.
  5. replace_with_partial_sort Checks if it’s possible to replace SortExecs with PartialSortExec operators
Source§

impl PhysicalOptimizerRule for EnsureCooperative

Source§

impl PhysicalOptimizerRule for FilterPushdown

Source§

impl PhysicalOptimizerRule for JoinSelection

Source§

impl PhysicalOptimizerRule for LimitPushdown

Source§

impl PhysicalOptimizerRule for LimitedDistinctAggregation

Source§

impl PhysicalOptimizerRule for OutputRequirements

Source§

impl PhysicalOptimizerRule for ProjectionPushdown

Source§

impl PhysicalOptimizerRule for SanityCheckPlan

Source§

impl PhysicalOptimizerRule for TopKAggregation

Source§

impl PhysicalOptimizerRule for OptimizeAggregateOrder