fix duplicated any function rewrite (#13419)

This commit is contained in:
Artem Zuikov 2020-08-07 01:36:14 +03:00 committed by GitHub
parent cece629145
commit e05dc65e73
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 5 additions and 3 deletions

View File

@ -14,7 +14,7 @@ namespace DB
namespace namespace
{ {
bool extractIdentifiers(const ASTFunction & func, std::vector<ASTPtr *> & identifiers) bool extractIdentifiers(const ASTFunction & func, std::unordered_set<ASTPtr *> & identifiers)
{ {
for (auto & arg : func.arguments->children) for (auto & arg : func.arguments->children)
{ {
@ -30,7 +30,7 @@ bool extractIdentifiers(const ASTFunction & func, std::vector<ASTPtr *> & identi
return false; return false;
} }
else if (arg->as<ASTIdentifier>()) else if (arg->as<ASTIdentifier>())
identifiers.emplace_back(&arg); identifiers.emplace(&arg);
} }
return true; return true;
@ -67,7 +67,7 @@ void RewriteAnyFunctionMatcher::visit(const ASTFunction & func, ASTPtr & ast, Da
return; return;
} }
std::vector<ASTPtr *> identifiers; std::unordered_set<ASTPtr *> identifiers; /// implicit remove duplicates
if (!extractIdentifiers(func, identifiers)) if (!extractIdentifiers(func, identifiers))
return; return;

View File

@ -0,0 +1 @@
SELECT any(if(if(x, 1, 2) AS a_, a_, 0)) FROM (SELECT 1 AS x);