MCPcopy Create free account
hub / github.com/MaterializeInc/materialize / visit_function_mut

Method visit_function_mut

src/sql/src/plan/query.rs:6328–6371  ·  view source on GitHub ↗
(&mut self, func: &mut Function<Aug>)

Source from the content-addressed store, hash-verified

6326
6327impl<'a> VisitMut<'_, Aug> for AggregateTableFuncVisitor<'a> {
6328 fn visit_function_mut(&mut self, func: &mut Function<Aug>) {
6329 let item = match self.scx.get_item_by_resolved_name(&func.name) {
6330 Ok(i) => i,
6331 // Catching missing functions later in planning improves error messages.
6332 Err(_) => return,
6333 };
6334
6335 match item.func() {
6336 // We don't want to collect window aggregations, because these will be handled not by
6337 // plan_aggregate, but by plan_function.
6338 Ok(Func::Aggregate { .. }) if func.over.is_none() => {
6339 if self.within_aggregate {
6340 self.err = Some(sql_err!("nested aggregate functions are not allowed",));
6341 return;
6342 }
6343 self.aggs.push(func.clone());
6344 let Function {
6345 name: _,
6346 args,
6347 filter,
6348 over: _,
6349 distinct: _,
6350 } = func;
6351 if let Some(filter) = filter {
6352 self.visit_expr_mut(filter);
6353 }
6354 let old_within_aggregate = self.within_aggregate;
6355 self.within_aggregate = true;
6356 self.table_disallowed_context
6357 .push("aggregate function calls");
6358
6359 self.visit_function_args_mut(args);
6360
6361 self.within_aggregate = old_within_aggregate;
6362 self.table_disallowed_context.pop();
6363 }
6364 Ok(Func::Table { .. }) => {
6365 self.table_disallowed_context.push("other table functions");
6366 visit_mut::visit_function_mut(self, func);
6367 self.table_disallowed_context.pop();
6368 }
6369 _ => visit_mut::visit_function_mut(self, func),
6370 }
6371 }
6372
6373 fn visit_query_mut(&mut self, _query: &mut Query<Aug>) {
6374 // Don't go into subqueries.

Callers

nothing calls this directly

Calls 7

is_noneMethod · 0.80
funcMethod · 0.45
pushMethod · 0.45
cloneMethod · 0.45
visit_expr_mutMethod · 0.45
popMethod · 0.45

Tested by

no test coverage detected