Add comment for visiting children of select in ApplyWithGlobalVisitor

This commit is contained in:
vdimir 2022-05-13 10:49:02 +00:00
parent dc2a90a344
commit 976a274f91
No known key found for this signature in database
GPG Key ID: 6EE4CE2BEDC51862

View File

@ -96,6 +96,16 @@ void ApplyWithGlobalVisitor::visit(ASTPtr & ast)
}
}
/*
* We need to visit all children recursively because the WITH statement may appear in the subquery at the nested level.
* Behavior of `WITH ... UNION ALL ...` should be the same at the top level and inside the subquery.
*
* For example:
* SELECT * FROM (WITH (SELECT ... ) AS t SELECT ... UNION ALL SELECT ...)
* ^^^^^^^^^^^^ should be visited ^^^^^^^^^^^^^^^^
* or inside `WHERE .. IN` clause:
* SELECT * FROM ... WHERE x IN (WITH (SELECT ... ) AS t SELECT ... UNION ALL SELECT ...)
*/
for (auto & child : node_union->list_of_selects->children)
visit(child);
}