Merge pull request #16082 from CurtizJ/fix-bad-aggregation

Fix segfault with wrong aggregation in lambdas
This commit is contained in:
alexey-milovidov 2020-10-18 04:36:29 +03:00 committed by GitHub
commit 6dc5cb166f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 8 additions and 1 deletions

View File

@ -421,11 +421,17 @@ bool ExpressionAnalyzer::makeAggregateDescriptions(ActionsDAGPtr & actions)
aggregate.argument_names.resize(arguments.size());
DataTypes types(arguments.size());
const auto & index = actions->getIndex();
for (size_t i = 0; i < arguments.size(); ++i)
{
getRootActionsNoMakeSet(arguments[i], true, actions);
const std::string & name = arguments[i]->getColumnName();
types[i] = actions->getIndex().find(name)->second->result_type;
auto it = index.find(name);
if (it == index.end())
throw Exception(ErrorCodes::UNKNOWN_IDENTIFIER, "Unknown identifier (in aggregate function '{}'): {}", node->name, name);
types[i] = it->second->result_type;
aggregate.argument_names[i] = name;
}

View File

@ -0,0 +1 @@
SELECT arrayMap(x -> x * sum(x), range(10)); -- { serverError 47 }