Skip to main content

OptimizerRule

Trait OptimizerRule 

Source
pub trait OptimizerRule: Send + Sync {
    // Required methods
    fn name(&self) -> &str;
    fn apply(&self, plan: &LogicalPlan) -> Option<LogicalPlan>;
}
Expand description

A rule that transforms a LogicalPlan into a (possibly better) one.

P2.4: apply returns Option<LogicalPlan>None means the plan is unchanged, allowing Optimizer to skip the clone-and-compare cycle and to record only rules that actually fired.

Required Methods§

Source

fn name(&self) -> &str

Short, stable rule name used in explain and diagnostics output.

Source

fn apply(&self, plan: &LogicalPlan) -> Option<LogicalPlan>

Apply the rule to plan.

Return Some(new_plan) when the rule rewrites the plan, or None when the plan is unchanged. Returning None is more efficient than returning a clone of the original plan unchanged.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§