Fix unused with column

This commit is contained in:
Amos Bird 2021-01-19 23:27:16 +08:00
parent 3ca0bdc848
commit 0b74d146ef
No known key found for this signature in database
GPG Key ID: 80D430DCBECFEDB4

View File

@ -123,8 +123,12 @@ void RequiredSourceColumnsMatcher::visit(const ASTSelectQuery & select, const AS
std::vector<ASTPtr *> out;
for (const auto & node : select.children)
if (node != select.select())
{
// We should not go into WITH statement because all needed aliases are already expanded to
// the right place after normalization. And it might contain unused unknown columns.
if (node != select.select() && node != select.with())
Visitor(data).visit(node);
}
/// revisit select_expression_list (with children) when all the aliases are set
Visitor(data).visit(select.select());