**Describe the situation**
There is a setting `optimize_move_functions_out_of_any` that is turn on by default.
It moves functions out of `any` aggregate function.
But it's not always beneficial.

Example:
```
any(substring(large_string, 1, 10))
```
is better than
```
substring(any(large_string), 1, 10)
```

#include <Common/typeid_cast.h>
#include <Parsers/ASTLiteral.h>
#include <Parsers/ASTFunction.h>
#include <Parsers/ASTIdentifier.h>
#include <Parsers/ASTSubquery.h>
#include <Interpreters/RewriteAnyFunctionVisitor.h>
#include <AggregateFunctions/AggregateFunctionFactory.h>
#include <IO/WriteHelpers.h>
#include <Parsers/ASTTablesInSelectQuery.h>
namespace DB
{
namespace
{
bool extractIdentifiers(const ASTFunction & func, std::unordered_set<ASTPtr *> & identifiers)
{
    for (auto & arg : func.arguments->children)
    {
        if (const auto * arg_func = arg->as<ASTFunction>())
        {
            
            
            
            
            ///     ┌─number─┬─arrayJoin(array(array(), array()))─┐
            ///     │                                       │