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.
{
    return addAlias(getNode(name), alias, can_replace);
}
ActionsDAG::Node & ActionsDAG::addAlias(Node & child, std::string alias, bool can_replace)
{
    Node node;
    node.type = ActionType::ALIAS;
    node.result_type = child.result_type;
    node.result_name = std::move(alias);
    node.column = child.column;
    node.children.emplace_back(&child);
    return addNode(std::move(node), can_replace);
}
const ActionsDAG::Node & ActionsDAG::addArrayJoin(const std::string & source_name, std::string result_name)
{
    auto & child = getNode(source_name);
    const DataTypeArray * array_type = typeid_cast<const DataTypeArray *>(child.result_type.get());
    if (!array_type)
        throw Exception("ARRAY JOIN requires array argument", ErrorCodes::TYPE_MISMATCH);
    Node node;
    node.type = ActionType::ARRAY_JOIN;
    node.result_type = array_type->getNestedType();
    node.result_name = std::move(result_name);
    node.children.emplace_back(&child);
    return addNode(std::move(node));
}
const ActionsDAG::Node & ActionsDAG::addFunction(