Skip to main content

transform_recursive

Function transform_recursive 

Source
pub fn transform_recursive<F>(
    expr: Expression,
    transform_fn: &F,
) -> Result<Expression>
Expand description

Applies a transform function bottom-up through an entire expression tree.

This is the core tree-rewriting engine used by the dialect system. It performs a post-order (children-first) traversal: for each node, all children are recursively transformed before the node itself is passed to transform_fn. This bottom-up strategy means that when transform_fn sees a node, its children have already been rewritten, which simplifies pattern matching on sub-expressions.

The function handles all expression variants including SELECT clauses (FROM, WHERE, GROUP BY, HAVING, ORDER BY, QUALIFY, WITH/CTEs, WINDOW), binary operators, function calls, CASE expressions, date/time functions, and more.

§Arguments

  • expr - The root expression to transform (consumed).
  • transform_fn - A closure that receives each expression node (after its children have been transformed) and returns a possibly-rewritten expression.

§Errors

Returns an error if transform_fn returns an error for any node.