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

Function removeAliasesRecursive

src/Analyzer/Resolve/QueryAnalyzer.cpp:207–222  ·  view source on GitHub ↗

Recursively clears aliases from `node` and all of its descendants, stopping at nested-scope boundaries (`QUERY`, `UNION`, `LAMBDA`). Background: during identifier resolution, when an identifier resolves to an alias (e.g. `cond` in `PREWHERE cond` resolves to the projection alias `cond`), the alias body is deep-cloned and the clone replaces the identifier. Only the clone's root is registered for l

Source from the content-addressed store, hash-verified

205/// scopes that are responsible for their own alias cleanup, so the walk stops at their
206/// boundary.
207void removeAliasesRecursive(QueryTreeNodePtr & node)
208{
209 if (!node)
210 return;
211
212 node->removeAlias();
213
214 auto node_type = node->getNodeType();
215 if (node_type == QueryTreeNodeType::QUERY
216 || node_type == QueryTreeNodeType::UNION
217 || node_type == QueryTreeNodeType::LAMBDA)
218 return;
219
220 for (auto & child : node->getChildren())
221 removeAliasesRecursive(child);
222}
223
224}
225

Callers 1

resolveQueryMethod · 0.85

Calls 3

removeAliasMethod · 0.80
getNodeTypeMethod · 0.45
getChildrenMethod · 0.45

Tested by

no test coverage detected