Another attempt.

This commit is contained in:
Nikolai Kochetov 2024-03-22 10:51:01 +00:00
parent 89d80a4d65
commit ec134d2642

View File

@ -802,7 +802,7 @@ struct IdentifierResolveScope
struct ResolvedFunctionsCache
{
FunctionOverloadResolverPtr resolver;
std::map<IQueryTreeNode::Hash, FunctionBasePtr> cache;
FunctionBasePtr function_base;
};
std::map<IQueryTreeNode::Hash, ResolvedFunctionsCache> functions_cache;
@ -931,24 +931,6 @@ struct IdentifierResolveScope
}
};
IQueryTreeNode::Hash getHashForFunctionArguments(const ColumnsWithTypeAndName & arguments)
{
SipHash hash;
for (const auto & arg : arguments)
{
auto type_name = arg.type->getName();
hash.update(type_name.c_str(), type_name.size());
if (arg.column)
{
if (const auto * col_const = typeid_cast<const ColumnConst *>(arg.column.get()))
col_const->updateHashWithValue(0, hash);
}
}
return getSipHash128AsPair(hash);
}
/** Visitor that extracts expression and function aliases from node and initialize scope tables with it.
* Does not go into child lambdas and queries.
@ -5798,8 +5780,7 @@ ProjectionNames QueryAnalyzer::resolveFunction(QueryTreeNodePtr & node, Identifi
FunctionBasePtr function_base;
if (function_cache)
{
auto args_hash = getHashForFunctionArguments(argument_columns);
auto & cached_function = function_cache->cache[args_hash];
auto & cached_function = function_cache->function_base;
if (!cached_function)
cached_function = function->build(argument_columns);