fix segfault with wrong aggregation in lambdas

This commit is contained in:
Anton Popov 2020-10-16 16:03:54 +03:00
parent e89a3b5d09
commit 0de364ec94
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 }