Small fixup.

This commit is contained in:
Yarik Briukhovetskyi 2024-11-20 20:10:04 +01:00 committed by GitHub
parent a7c3acd90c
commit e81c5171b7
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -114,31 +114,15 @@ void QueryAliasesMatcher<T>::visit(const ASTSubquery & const_subquery, const AST
subquery.prefer_alias_to_column_name = true;
}
template <typename T>
bool QueryAliasesMatcher<T>::checkIfNamesAreSame(Data & data, const ASTPtr & ast)
{
String name = ast->getColumnName();
for (const auto & obj : data)
{
if (obj.second->getColumnName() == name)
return true;
}
return false;
}
template <typename T>
void QueryAliasesMatcher<T>::visitOther(const ASTPtr & ast, Data & data)
{
auto & aliases = data;
String alias = ast->tryGetAlias();
if (!alias.empty())
{
if (aliases.contains(alias) && ast->getTreeHash(/*ignore_aliases=*/ true) != aliases[alias]->getTreeHash(/*ignore_aliases=*/ true))
{
if (checkIfNamesAreSame(aliases, ast))
throw Exception(wrongAliasMessage(ast, aliases[alias], alias), ErrorCodes::MULTIPLE_EXPRESSIONS_FOR_ALIAS);
}
aliases[alias] = ast;
}