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
| 205 | /// scopes that are responsible for their own alias cleanup, so the walk stops at their |
| 206 | /// boundary. |
| 207 | void 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 |
no test coverage detected