MCPcopy Create free account
hub / github.com/apache/datafusion / map_children

Method map_children

datafusion/expr/src/tree_node.rs:124–350  ·  view source on GitHub ↗

Maps each child of `self` using the provided closure `f`. The closure `f` takes ownership of an expression and returns a `Transformed` result, indicating whether the expression was transformed or left unchanged.

(
        self,
        f: F,
    )

Source from the content-addressed store, hash-verified

122 /// The closure `f` takes ownership of an expression and returns a `Transformed` result,
123 /// indicating whether the expression was transformed or left unchanged.
124 fn map_children<F: FnMut(Self) -> Result<Transformed<Self>>>(
125 self,
126 f: F,
127 ) -> Result<Transformed<Self>> {
128 Ok(match self {
129 // TODO: remove the next line after `Expr::Wildcard` is removed
130 #[expect(deprecated)]
131 Expr::Column(_)
132 | Expr::Wildcard { .. }
133 | Expr::Placeholder(Placeholder { .. })
134 | Expr::OuterReferenceColumn(_, _)
135 | Expr::Exists { .. }
136 | Expr::ScalarSubquery(_)
137 | Expr::ScalarVariable(_, _)
138 | Expr::Literal(_, _)
139 | Expr::LambdaVariable(_) => Transformed::no(self),
140 Expr::SetComparison(SetComparison {
141 expr,
142 subquery,
143 op,
144 quantifier,
145 }) => expr.map_elements(f)?.update_data(|expr| {
146 Expr::SetComparison(SetComparison {
147 expr,
148 subquery,
149 op,
150 quantifier,
151 })
152 }),
153 Expr::Unnest(Unnest { expr, .. }) => expr
154 .map_elements(f)?
155 .update_data(|expr| Expr::Unnest(Unnest { expr })),
156 Expr::Alias(Alias {
157 expr,
158 relation,
159 name,
160 metadata,
161 }) => expr.map_elements(f)?.update_data(|expr| {
162 Expr::Alias(Alias {
163 expr,
164 relation,
165 name,
166 metadata,
167 })
168 }),
169 Expr::InSubquery(InSubquery {
170 expr,
171 subquery,
172 negated,
173 }) => expr.map_elements(f)?.update_data(|be| {
174 Expr::InSubquery(InSubquery::new(be, subquery, negated))
175 }),
176 Expr::BinaryExpr(BinaryExpr { left, op, right }) => (left, right)
177 .map_elements(f)?
178 .update_data(|(new_left, new_right)| {
179 Expr::BinaryExpr(BinaryExpr::new(new_left, op, new_right))
180 }),
181 Expr::Like(Like {

Callers 8

insert_belowFunction · 0.45
rewrite_childrenFunction · 0.45
rewriteMethod · 0.45
optimize_projectionsFunction · 0.45
optimize_internalMethod · 0.45
optimizeMethod · 0.45
rewriteMethod · 0.45

Calls 15

SetComparisonClass · 0.85
AliasClass · 0.85
InSubqueryClass · 0.85
newFunction · 0.85
LikeClass · 0.85
BetweenClass · 0.85
CaseClass · 0.85
CastClass · 0.85
TryCastClass · 0.85
ScalarFunctionClass · 0.85
GroupingSetEnum · 0.85
InListClass · 0.85

Tested by

no test coverage detected