Better fix

This commit is contained in:
Ivan Lezhankin 2020-11-22 22:50:34 +03:00
parent 1002148886
commit 10747fd7c3
2 changed files with 4 additions and 5 deletions

View File

@ -34,7 +34,6 @@ void MarkTableIdentifiersMatcher::visit(const ASTFunction & func, ASTPtr & ptr,
auto opt_name = tryGetIdentifierName(ast);
if (opt_name && !data.aliases.count(*opt_name) && ast->as<ASTIdentifier>())
{
ptr = func.clone();
ptr->as<ASTFunction>()->arguments->children[1] = ast->as<ASTIdentifier>()->createTable();
assert(ptr->as<ASTFunction>()->arguments->children[1]);
}
@ -46,11 +45,11 @@ void MarkTableIdentifiersMatcher::visit(const ASTFunction & func, ASTPtr & ptr,
{
if (func.arguments->children.empty())
return;
auto ast = func.arguments->children.at(0);
auto opt_name = tryGetIdentifierName(ast);
if (opt_name && !data.aliases.count(*opt_name) && ast->as<ASTIdentifier>())
{
ptr = func.clone();
ptr->as<ASTFunction>()->arguments->children[0] = ast->as<ASTIdentifier>()->createTable();
assert(ptr->as<ASTFunction>()->arguments->children[0]);
}

View File

@ -739,13 +739,13 @@ void TreeRewriter::normalize(ASTPtr & query, Aliases & aliases, const Settings &
CustomizeAggregateFunctionsOrNullVisitor(data_or_null).visit(query);
}
/// Creates a dictionary `aliases`: alias -> ASTPtr
QueryAliasesVisitor(aliases).visit(query);
/// Mark table ASTIdentifiers with not a column marker
MarkTableIdentifiersVisitor::Data identifiers_data{aliases};
MarkTableIdentifiersVisitor(identifiers_data).visit(query);
/// Creates a dictionary `aliases`: alias -> ASTPtr
QueryAliasesVisitor(aliases).visit(query);
/// Common subexpression elimination. Rewrite rules.
QueryNormalizer::Data normalizer_data(aliases, settings);
QueryNormalizer(normalizer_data).visit(query);