Skip to main content

substitute_outer_references

Function substitute_outer_references 

Source
pub fn substitute_outer_references(
    expr: &Expression,
    outer_row: &FxHashMap<CompactArc<str>, Value>,
) -> Expression
Expand description

Substitute outer references in an expression with their actual values.

This is used for correlated subqueries to enable predicate pushdown. When we have a WHERE clause like o.user_id = u.id where u.id is an outer reference, this function replaces u.id with its actual value (e.g., 42), allowing the expression o.user_id = 42 to be pushed down to storage for index usage.

§Arguments

  • expr - The expression to transform
  • outer_row - Map of outer column names to their values

§Returns

A new expression with outer references replaced by literal values. Uses copy-on-write semantics: only clones when substitution is actually needed.