pub struct ExtractLeafExpressions {}Expand description
Extracts MoveTowardsLeafNodes sub-expressions from non-projection nodes
into extraction projections (pass 1 of 2).
This handles Filter, Sort, Limit, Aggregate, and Join nodes. For Projection
nodes, extraction and pushdown are handled by PushDownLeafProjections.
§Key Concepts
Extraction projection: a projection inserted below a node that
pre-computes a cheap expression and exposes it under an alias
(__datafusion_extracted_N). The parent node then references the alias
instead of the original expression.
Recovery projection: a projection inserted above a node to restore the original output schema when extraction changes it. Schema-preserving nodes (Filter, Sort, Limit) gain extra columns from the extraction projection that bubble up; the recovery projection selects only the original columns to hide the extras.
§Example
Given a filter with a struct field access:
Filter: user['status'] = 'active'
TableScan: t [id, user]This rule:
- Inserts an extraction projection below the filter:
- Adds a recovery projection above to hide the extra column:
Projection: id, user <-- recovery projection
Filter: __datafusion_extracted_1 = 'active'
Projection: user['status'] AS __datafusion_extracted_1, id, user <-- extraction projection
TableScan: t [id, user]Important: The PushDownFilter rule is aware of projections created by this rule
and will not push filters through them. It uses ExpressionPlacement to detect
MoveTowardsLeafNodes expressions and skip filter pushdown past them.
Implementations§
Source§impl ExtractLeafExpressions
impl ExtractLeafExpressions
Sourcepub fn new() -> Self
pub fn new() -> Self
Create a new ExtractLeafExpressions
Trait Implementations§
Source§impl Debug for ExtractLeafExpressions
impl Debug for ExtractLeafExpressions
Source§impl Default for ExtractLeafExpressions
impl Default for ExtractLeafExpressions
Source§fn default() -> ExtractLeafExpressions
fn default() -> ExtractLeafExpressions
Source§impl OptimizerRule for ExtractLeafExpressions
impl OptimizerRule for ExtractLeafExpressions
Source§fn rewrite(
&self,
plan: LogicalPlan,
config: &dyn OptimizerConfig,
) -> Result<Transformed<LogicalPlan>>
fn rewrite( &self, plan: LogicalPlan, config: &dyn OptimizerConfig, ) -> Result<Transformed<LogicalPlan>>
plan to an optimized form, returning Transformed::yes
if the plan was rewritten and Transformed::no if it was not. Read moreSource§fn apply_order(&self) -> Option<ApplyOrder>
fn apply_order(&self) -> Option<ApplyOrder>
ApplyOrder for details. Read moreSource§fn supports_rewrite(&self) -> bool
fn supports_rewrite(&self) -> bool
This method is no longer used
Auto Trait Implementations§
impl Freeze for ExtractLeafExpressions
impl RefUnwindSafe for ExtractLeafExpressions
impl Send for ExtractLeafExpressions
impl Sync for ExtractLeafExpressions
impl Unpin for ExtractLeafExpressions
impl UnsafeUnpin for ExtractLeafExpressions
impl UnwindSafe for ExtractLeafExpressions
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more