MCPcopy Create free account
hub / github.com/ClickHouse/ClickHouse / extractAllTableReferences

Function extractAllTableReferences

src/Analyzer/Utils.cpp:532–599  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

530}
531
532QueryTreeNodes extractAllTableReferences(const QueryTreeNodePtr & tree)
533{
534 QueryTreeNodes result;
535
536 QueryTreeNodes nodes_to_process;
537 nodes_to_process.push_back(tree);
538
539 while (!nodes_to_process.empty())
540 {
541 auto node_to_process = std::move(nodes_to_process.back());
542 nodes_to_process.pop_back();
543
544 auto node_type = node_to_process->getNodeType();
545
546 switch (node_type)
547 {
548 case QueryTreeNodeType::TABLE:
549 {
550 result.push_back(std::move(node_to_process));
551 break;
552 }
553 case QueryTreeNodeType::QUERY:
554 {
555 nodes_to_process.push_back(node_to_process->as<QueryNode>()->getJoinTree());
556 break;
557 }
558 case QueryTreeNodeType::UNION:
559 {
560 for (const auto & union_node : node_to_process->as<UnionNode>()->getQueries().getNodes())
561 nodes_to_process.push_back(union_node);
562 break;
563 }
564 case QueryTreeNodeType::TABLE_FUNCTION:
565 {
566 // Arguments of table function can't contain TableNodes.
567 break;
568 }
569 case QueryTreeNodeType::ARRAY_JOIN:
570 {
571 nodes_to_process.push_back(node_to_process->as<ArrayJoinNode>()->getTableExpression());
572 break;
573 }
574 case QueryTreeNodeType::CROSS_JOIN:
575 {
576 auto & cross_join_node = node_to_process->as<CrossJoinNode &>();
577 for (const auto & expr : cross_join_node.getTableExpressions())
578 nodes_to_process.push_back(expr);
579 break;
580 }
581 case QueryTreeNodeType::JOIN:
582 {
583 auto & join_node = node_to_process->as<JoinNode &>();
584 nodes_to_process.push_back(join_node.getRightTableExpression());
585 nodes_to_process.push_back(join_node.getLeftTableExpression());
586 break;
587 }
588 default:
589 {

Callers 4

readMethod · 0.85

Calls 8

getNodesMethod · 0.80
getNodeTypeNameMethod · 0.80
ExceptionClass · 0.50
push_backMethod · 0.45
emptyMethod · 0.45
backMethod · 0.45
pop_backMethod · 0.45
getNodeTypeMethod · 0.45

Tested by

no test coverage detected