MCPcopy Create free account
hub / github.com/ByConity/ByConity / visitChildren

Method visitChildren

src/Interpreters/QueryNormalizer.cpp:397–437  ·  view source on GitHub ↗

Don't go into subqueries. Don't go into select query. It processes children itself. Do not go to the left argument of lambda expressions, so as not to replace the formal parameters on aliases in expressions of the form 123 AS x, arrayMap(x -> 1, [2]).

Source from the content-addressed store, hash-verified

395/// Do not go to the left argument of lambda expressions, so as not to replace the formal parameters
396/// on aliases in expressions of the form 123 AS x, arrayMap(x -> 1, [2]).
397void QueryNormalizer::visitChildren(IAST * node, Data & data)
398{
399 if (auto * func_node = node->as<ASTFunction>())
400 {
401 if (func_node->tryGetQueryArgument())
402 {
403 if (func_node->name != "view")
404 throw Exception("Query argument can only be used in the `view` TableFunction", ErrorCodes::BAD_ARGUMENTS);
405 /// Don't go into query argument.
406 return;
407 }
408 /// We skip the first argument. We also assume that the lambda function can not have parameters.
409 size_t first_pos = 0;
410 if (func_node->name == "lambda")
411 first_pos = 1;
412
413 if (func_node->arguments)
414 {
415 auto & func_children = func_node->arguments->children;
416
417 for (size_t i = first_pos; i < func_children.size(); ++i)
418 {
419 auto & child = func_children[i];
420
421 if (needVisitChild(child))
422 visit(child, data);
423 }
424 }
425
426 if (func_node->window_definition)
427 {
428 visitChildren(func_node->window_definition.get(), data);
429 }
430 }
431 else if (!node->as<ASTSelectQuery>() && !node->as<ASTTablesInSelectQueryElement>())
432 {
433 for (auto & child : node->children)
434 if (needVisitChild(child))
435 visit(child, data);
436 }
437}
438
439void QueryNormalizer::visit(ASTPtr & ast, Data & data)
440{

Callers

nothing calls this directly

Calls 5

needVisitChildFunction · 0.85
tryGetQueryArgumentMethod · 0.80
ExceptionClass · 0.70
sizeMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected