Abnormal memory requirements for a query with string filter


Appeared fresh after upgrade to 21.3.2.5 

The table is not big - 480 mb compressed

Getting an error
```
SQL Error [241]: ClickHouse exception, code: 241, host: localhost, port: 8123; Code: 241, e.displayText() = DB::Exception: Memory limit (for query) exceeded: would use 1.00 EiB (attempt to allocate chunk of 1152921504606554384 bytes), maximum: 101.47 GiB: While executing ConvertingAggregatedToChunksTransform (version 21.3.2.5 (official build))

The query is quite plain
SELECT 
       FirstScreen,
       "SessionResult" AS "SessionResult",
       count(*) AS count
FROM
  (SELECT FirstScreen,
          SessionResult,
          LastResponse,
          toDate(LastResponseDateTime),
          WasEligible,
          WasSessionSuccessfull,
          COUNT (*)
   FROM MPTUSSDSESSIONS
   GROUP by FirstScreen,
            SessionResult,
            LastResponse,
            toDate(LastResponseDateTime),
            WasEligible,
            WasSessionSuccessfull) AS expr_qry
WHERE  "SessionResult" NOT IN ('unknown result')
  AND "WasSessionSuccessfull" ='Y'
GROUP BY FirstScreen,  "SessionResult"
ORDER BY count DESC
LIMIT 10000;
```

Most interesting - when line  `AND "WasSessionSuccessfull" ='Y' ` is removed from the query it completes ok.
#if USE_EMBEDDED_COMPILER
    if (first.compilation_cache == nullptr)
        first.compilation_cache = second.compilation_cache;
#endif
    first.settings.max_temporary_columns = std::max(first.settings.max_temporary_columns, second.settings.max_temporary_columns);
    first.settings.max_temporary_non_const_columns = std::max(first.settings.max_temporary_non_const_columns, second.settings.max_temporary_non_const_columns);
    first.settings.min_count_to_compile_expression = std::max(first.settings.min_count_to_compile_expression, second.settings.min_count_to_compile_expression);
    first.settings.projected_output = second.settings.projected_output;
    
    first.removeUnusedActions();
    return std::make_shared<ActionsDAG>(std::move(first));
}
ActionsDAG::SplitResult ActionsDAG::split(std::unordered_set<const Node *> split_nodes) const
{
    
    
    
    std::list<Node> second_nodes;
    std::list<Node> first_nodes;
    Index second_index;
    Index first_index;
    
    std::vector<const Node *> new_inputs;
    struct Frame
    {
        const Node * node;
        size_t next_child_to_visit = 0;
    };
    struct Data
    {